aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/hipe/icode/hipe_icode_coordinator.erl29
1 files changed, 23 insertions, 6 deletions
diff --git a/lib/hipe/icode/hipe_icode_coordinator.erl b/lib/hipe/icode/hipe_icode_coordinator.erl
index d2f8748535..b073954ce7 100644
--- a/lib/hipe/icode/hipe_icode_coordinator.erl
+++ b/lib/hipe/icode/hipe_icode_coordinator.erl
@@ -106,12 +106,29 @@ handle_no_change_done(MFA, {Queue, Busy}) ->
{Queue, Busy -- [MFA]}.
last_action(PM, ServerPid, Mod, All) ->
- lists:foreach(fun (MFA) ->
- gb_trees:get(MFA, PM) ! {done, final_funs(ServerPid, Mod)},
- receive
- {done_rewrite, MFA} -> ok
- end
- end, All).
+ last_action(PM, ServerPid, Mod, All, []).
+
+last_action(_, _, _, [], []) -> ok;
+last_action(PM, ServerPid, Mod, [], [MFA|Busy]) ->
+ receive
+ {done_rewrite, MFA} ->
+ last_action(PM, ServerPid, Mod, [], Busy)
+ end;
+last_action(PM, ServerPid, Mod, All0, Busy) ->
+ receive
+ {done_rewrite, MFA} ->
+ last_action(PM, ServerPid, Mod, All0, Busy -- [MFA])
+ after 0 ->
+ case ?MAX_CONCURRENT - length(Busy) of
+ X when is_integer(X), X > 0 ->
+ [MFA|All1] = All0,
+ gb_trees:get(MFA, PM) ! {done, final_funs(ServerPid, Mod)},
+ last_action(PM, ServerPid, Mod, All1, [MFA|Busy]);
+ X when is_integer(X) ->
+ Busy1 = receive {done_rewrite, MFA} -> Busy -- [MFA] end,
+ last_action(PM, ServerPid, Mod, All0, Busy1)
+ end
+ end.
restart_funs({Queue, Busy} = QB, PM, All, ServerPid) ->
case ?MAX_CONCURRENT - length(Busy) of