summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/rabbit.erl27
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("#").