diff options
author | Magnus Lång <[email protected]> | 2016-03-18 12:12:58 +0100 |
---|---|---|
committer | Magnus Lång <[email protected]> | 2016-07-11 17:38:18 +0200 |
commit | 89a6d16fa71870bf496bbe477a3f2c7854396e07 (patch) | |
tree | 8a689501dccad58e676243e09e20dcdd6fef24c5 /lib/hipe/icode | |
parent | ad73c37d4af90834c62f961264dce00118309b0f (diff) | |
download | otp-89a6d16fa71870bf496bbe477a3f2c7854396e07.tar.gz otp-89a6d16fa71870bf496bbe477a3f2c7854396e07.tar.bz2 otp-89a6d16fa71870bf496bbe477a3f2c7854396e07.zip |
hipe_icode_coordinator: Rewrite concurrently
Diffstat (limited to 'lib/hipe/icode')
-rw-r--r-- | lib/hipe/icode/hipe_icode_coordinator.erl | 29 |
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 |