diff options
| author | Simon MacMullen <simon@rabbitmq.com> | 2011-10-28 16:01:50 +0100 |
|---|---|---|
| committer | Simon MacMullen <simon@rabbitmq.com> | 2011-10-28 16:01:50 +0100 |
| commit | dac47d81cc7ed1e029071bdae9a1f3377293fcb8 (patch) | |
| tree | 538c07b05c1da867351915ce9bfc35a94989b2c3 /src | |
| parent | 3c5a49e31e7d434f3d6b6e4d5830a597fca211ef (diff) | |
| download | rabbitmq-server-git-dac47d81cc7ed1e029071bdae9a1f3377293fcb8.tar.gz | |
And don't send a ref, use a monitor instead. That way we don't need to try / catch in the spawned process.
Diffstat (limited to 'src')
| -rw-r--r-- | src/rabbit.erl | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/src/rabbit.erl b/src/rabbit.erl index 90e95a9e07..fe5e7f2c8e 100644 --- a/src/rabbit.erl +++ b/src/rabbit.erl @@ -254,34 +254,27 @@ hipe_compile() -> io:format("HiPE compiling: |~s|~n |", [string:copies("-", Count)]), T1 = erlang:now(), - S = self(), - Ref = make_ref(), - [spawn(fun () -> hipe_compile(S, Ref, Ms) end) - || Ms <- split(?HIPE_WORTHY, ?HIPE_PROCESSES)], - wait(Ref, ?HIPE_PROCESSES), + PidMRefs = [spawn_monitor(fun () -> hipe_compile(Ms) end) + || Ms <- split(?HIPE_WORTHY, ?HIPE_PROCESSES)], + wait([MRef || {_Pid, MRef} <- PidMRefs]), T2 = erlang:now(), T = timer:now_diff(T2, T1) div 1000000, io:format("|~n~nCompiled ~B modules in ~Bs~n", [Count, T]). -wait(_ , 0) -> ok; -wait(Ref, C) -> receive - Ref -> wait(Ref, C - 1); - {error, E} -> exit(E) - end. +wait(MRefs) -> [receive + {'DOWN', MRef, process, _, normal} -> ok; + {'DOWN', MRef, process, _, Reason} -> exit(Reason) + end || MRef <- MRefs]. split(L, N) -> split0(L, [[] || _ <- lists:seq(1, N)]). split0([], Ls) -> Ls; split0([I | Is], [L | Ls]) -> split0(Is, Ls ++ [[I | L]]). -hipe_compile(S, Ref, Ms) -> - S ! try [hipe_compile(M) || M <- Ms], - Ref - catch _:E -> - {error, E} - end. +hipe_compile(Ms) -> + [hipe_compile0(M) || M <- Ms]. -hipe_compile(M) -> +hipe_compile0(M) -> {ok, M} = hipe:c(M, [o3]), io:format("#"). |
