Seems to work
[makerl.git] / src / scratch.erl
blob0a3d8d5f069534eaa7f583d578506a7952a2242e
1 %%%-------------------------------------------------------------------
2 %%% File : scratch.erl
3 %%% Author : <>
4 %%% Description :
5 %%%
6 %%% Created : 10 Oct 2011 by <>
7 %%%-------------------------------------------------------------------
8 -module(scratch).
9 -compile(export_all).
11 spawner(Bandwith, Func, List) ->
12 mkrl_exec_host_node:start(spawner, Bandwith),
13 [ mkrl_exec_host_node:submit(spawner,
14 erlang,
15 apply, [Func, [N]])
16 || N <- List ],
17 Waiter = fun() ->
18 receive {host_done, _Pid, Result} ->
19 Result
20 after 20000 ->
21 timeout
22 end
23 end,
24 Res = lists:foldl(fun(_, Ac) ->
25 [ Waiter() | Ac ]
26 end,
27 [],
28 List),
29 try
30 mkrl_exec_host_node:stop(spawner)
31 catch
32 Error:Reason -> io:format("Caught ~p:~p~n", [Error, Reason])
33 end,
34 Res.
37 %% timer:tc(scratch, spawner, [10, fun(X) -> timer:sleep(100), X end, lists:seq(1, 20)]).