diff options
author | Rickard Green <[email protected]> | 2013-11-08 17:41:20 +0100 |
---|---|---|
committer | Rickard Green <[email protected]> | 2013-11-18 20:12:36 +0100 |
commit | 406fd5c773b5ae73dbfc6b305a502ffbe236a9bb (patch) | |
tree | 20d53ada8fdd2d7693c5025817ecad6cdd38aab0 /erts | |
parent | ca0425c6ff85262bc15367f5fd9cbc51cde52b20 (diff) | |
download | otp-406fd5c773b5ae73dbfc6b305a502ffbe236a9bb.tar.gz otp-406fd5c773b5ae73dbfc6b305a502ffbe236a9bb.tar.bz2 otp-406fd5c773b5ae73dbfc6b305a502ffbe236a9bb.zip |
Use asynchronous check_process_code in code_parallel_SUITE
Diffstat (limited to 'erts')
-rw-r--r-- | erts/emulator/test/code_parallel_load_SUITE.erl | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/erts/emulator/test/code_parallel_load_SUITE.erl b/erts/emulator/test/code_parallel_load_SUITE.erl index 1cfe015ea6..428f1242ab 100644 --- a/erts/emulator/test/code_parallel_load_SUITE.erl +++ b/erts/emulator/test/code_parallel_load_SUITE.erl @@ -159,22 +159,34 @@ setup_checkers(_,0) -> []; setup_checkers(T,N) -> [spawn_link(fun() -> ?model:check(T) end) | setup_checkers(T, N-1)]. check_and_purge_processes_code(Pids, M) -> - check_and_purge_processes_code(Pids, M, []). -check_and_purge_processes_code([], M, []) -> + Tag = make_ref(), + N = request_cpc(Pids, M, Tag), + ok = handle_cpc_responses(N, Tag, M), erlang:purge_module(M), + ok. + +request_cpc(Pid, M, Tag) when is_pid(Pid) -> + erlang:check_process_code(Pid, M, [{async, {Tag, Pid}}]), + 1; +request_cpc(Pids, M, Tag) when is_list(Pids) -> + request_cpc(Pids, M, Tag, 0). + +request_cpc([], _M, _Tag, N) -> + N; +request_cpc([Pid|Pids], M, Tag, N) -> + request_cpc(Pids, M, Tag, N + request_cpc(Pid, M, Tag)). + +handle_cpc_responses(0, _Tag, _Module) -> ok; -check_and_purge_processes_code([], M, Pending) -> - io:format("Processes ~w are still executing old code - retrying.~n", [Pending]), - check_and_purge_processes_code(Pending, M, []); -check_and_purge_processes_code([Pid|Pids], M, Pending) -> - case erlang:check_process_code(Pid, M) of - false -> - check_and_purge_processes_code(Pids, M, Pending); - true -> - check_and_purge_processes_code(Pids, M, [Pid|Pending]) +handle_cpc_responses(N, Tag, Module) -> + receive + {check_process_code, {Tag, _Pid}, false} -> + handle_cpc_responses(N-1, Tag, Module); + {check_process_code, {Tag, Pid}, true} -> + 1 = request_cpc(Pid, Module, Tag), + handle_cpc_responses(N, Tag, Module) end. - generate(Module, Attributes, FunStrings) -> FunForms = function_forms(FunStrings), Forms = [ |