aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLuca Favatella <[email protected]>2015-09-24 23:31:10 +0100
committerHans Bolinder <[email protected]>2016-01-27 08:58:32 +0100
commit7a2fc5f7ace6f0c3fc03e1f74f6cedf95c7968fd (patch)
treef86ca2d6463615cb5c7fefcb99f73065ab0a202b /lib
parentb33819468f741b608afd03076bf1c14dafaa3887 (diff)
downloadotp-7a2fc5f7ace6f0c3fc03e1f74f6cedf95c7968fd.tar.gz
otp-7a2fc5f7ace6f0c3fc03e1f74f6cedf95c7968fd.tar.bz2
otp-7a2fc5f7ace6f0c3fc03e1f74f6cedf95c7968fd.zip
Reflect more init-loop OTP pattern in dialyzer_worker
Also clarify in which modes the states `updating` and `waiting` can happen in the loop.
Diffstat (limited to 'lib')
-rw-r--r--lib/dialyzer/src/dialyzer_worker.erl26
1 files changed, 14 insertions, 12 deletions
diff --git a/lib/dialyzer/src/dialyzer_worker.erl b/lib/dialyzer/src/dialyzer_worker.erl
index 39d88375b8..bae12b21c3 100644
--- a/lib/dialyzer/src/dialyzer_worker.erl
+++ b/lib/dialyzer/src/dialyzer_worker.erl
@@ -59,16 +59,21 @@ launch(Mode, Job, InitData, Coordinator) ->
job = Job,
init_data = InitData,
coordinator = Coordinator},
- InitState =
- case Mode of
- X when X =:= 'typesig'; X =:= 'dataflow' -> initializing;
- X when X =:= 'compile'; X =:= 'warnings' -> running
- end,
- spawn_link(fun() -> loop(InitState, State) end).
+ spawn_link(fun() -> init(State) end).
%%--------------------------------------------------------------------
-loop(updating, State) ->
+init(#state{job = SCC, mode = Mode, init_data = InitData} = State) when
+ Mode =:= 'typesig'; Mode =:= 'dataflow' ->
+ DependsOn = dialyzer_succ_typings:find_depends_on(SCC, InitData),
+ ?debug("Deps ~p: ~p\n",[SCC, DependsOn]),
+ loop(updating, State#state{depends_on = DependsOn});
+init(#state{mode = Mode} = State) when
+ Mode =:= 'compile'; Mode =:= 'warnings' ->
+ loop(running, State).
+
+loop(updating, #state{mode = Mode} = State) when
+ Mode =:= 'typesig'; Mode =:= 'dataflow' ->
?debug("Update: ~p\n",[State#state.job]),
NextStatus =
case waits_more_success_typings(State) of
@@ -76,11 +81,8 @@ loop(updating, State) ->
false -> running
end,
loop(NextStatus, State);
-loop(initializing, #state{job = SCC, init_data = InitData} = State) ->
- DependsOn = dialyzer_succ_typings:find_depends_on(SCC, InitData),
- ?debug("Deps ~p: ~p\n",[State#state.job, DependsOn]),
- loop(updating, State#state{depends_on = DependsOn});
-loop(waiting, State) ->
+loop(waiting, #state{mode = Mode} = State) when
+ Mode =:= 'typesig'; Mode =:= 'dataflow' ->
?debug("Wait: ~p\n",[State#state.job]),
NewState = wait_for_success_typings(State),
loop(updating, NewState);