summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaimo Niskanen <raimo@erlang.org>2020-02-21 16:03:11 +0100
committerRaimo Niskanen <raimo@erlang.org>2020-02-21 16:03:11 +0100
commitf0a1c8d9e3ea410caa0ce00f2c2e9e1bebaba914 (patch)
tree8f40eb3c6001c0c61da6a53de9a8db52b74a7e61
parent28f9bd0dac889a532fde4a8b1d534fbdb0593703 (diff)
downloaderlang-f0a1c8d9e3ea410caa0ce00f2c2e9e1bebaba914.tar.gz
Improve function name
-rw-r--r--lib/stdlib/src/gen_statem.erl165
1 files changed, 83 insertions, 82 deletions
diff --git a/lib/stdlib/src/gen_statem.erl b/lib/stdlib/src/gen_statem.erl
index b8f1f3a9a2..2cf30e10ec 100644
--- a/lib/stdlib/src/gen_statem.erl
+++ b/lib/stdlib/src/gen_statem.erl
@@ -1501,90 +1501,17 @@ loop_actions_list(
Q)
end;
%%
- Timeout ->
- loop_actions_timeout(
- P, Debug, S, Q, NextState_NewData,
- NextEventsR, Hibernate, TimeoutsR, Postpone,
- CallEnter, StateCall, Actions, Timeout)
- end.
-
-%% Process a reply action
-%%
-loop_actions_reply(
- P, Debug, S, Q, NextState_NewData,
- NextEventsR, Hibernate, TimeoutsR, Postpone,
- CallEnter, StateCall, Actions,
- From, Reply) ->
- %%
- case from(From) of
- true ->
- %% No need for a separate ?not_sys_debug clause here
- %% since the external call to erlang:'!'/2 in reply/2
- %% will cause swap out of all live registers anyway
- reply(From, Reply),
- Debug_1 = ?sys_debug(Debug, P#params.name, {out,Reply,From}),
+ _ ->
loop_actions_list(
- P, Debug_1, S, Q, NextState_NewData,
+ P, Debug, S, Q, NextState_NewData,
NextEventsR, Hibernate, TimeoutsR, Postpone,
- CallEnter, StateCall, Actions);
- false ->
- terminate(
- error,
- {bad_action_from_state_function,{reply,From,Reply}},
- ?STACKTRACE(), P, Debug,
- S#state{
- state_data = NextState_NewData,
- hibernate = Hibernate},
- Q)
+ CallEnter, StateCall, Actions, Action)
end.
-%% Process a next_event action
+%% Process all other actions, i.e timeout actions,
+%% all others are unrecognized
%%
-loop_actions_next_event(
- P, Debug, S, Q, NextState_NewData,
- NextEventsR, Hibernate, TimeoutsR, Postpone,
- CallEnter, StateCall, Actions, Type, Content) ->
- case event_type(Type) of
- true when StateCall ->
- NextEvent = {Type,Content},
- case Debug of
- ?not_sys_debug ->
- loop_actions_list(
- P, Debug, S, Q, NextState_NewData,
- [NextEvent|NextEventsR],
- Hibernate, TimeoutsR, Postpone,
- CallEnter, StateCall, Actions);
- _ ->
- Name = P#params.name,
- {State,_Data} = S#state.state_data,
- Debug_1 =
- sys_debug(Debug, Name, {in,{Type,Content},State}),
- loop_actions_list(
- P, Debug_1, S, Q, NextState_NewData,
- [NextEvent|NextEventsR],
- Hibernate, TimeoutsR, Postpone,
- CallEnter, StateCall, Actions)
- end;
- _ ->
- terminate(
- error,
- {if
- StateCall ->
- bad_action_from_state_function;
- true ->
- bad_state_enter_action_from_state_function
- end,
- {next_event,Type,Content}},
- ?STACKTRACE(), P, Debug,
- S#state{
- state_data = NextState_NewData,
- hibernate = Hibernate},
- Q)
- end.
-
-%% Process a timeout action, or also any unrecognized action
-%%
-loop_actions_timeout(
+loop_actions_list(
P, Debug, S, Q, NextState_NewData,
NextEventsR, Hibernate, TimeoutsR, Postpone,
CallEnter, StateCall, Actions,
@@ -1651,7 +1578,7 @@ loop_actions_timeout(
hibernate = Hibernate},
Q)
end;
-loop_actions_timeout(
+loop_actions_list(
P, Debug, S, Q, NextState_NewData,
NextEventsR, Hibernate, TimeoutsR, Postpone,
CallEnter, StateCall, Actions,
@@ -1676,7 +1603,7 @@ loop_actions_timeout(
hibernate = Hibernate},
Q)
end;
-loop_actions_timeout(
+loop_actions_list(
P, Debug, S, Q, NextState_NewData,
NextEventsR, Hibernate, TimeoutsR, Postpone,
CallEnter, StateCall, Actions,
@@ -1700,7 +1627,7 @@ loop_actions_timeout(
hibernate = Hibernate},
Q)
end;
-loop_actions_timeout(
+loop_actions_list(
P, Debug, S, Q, NextState_NewData,
NextEventsR, Hibernate, TimeoutsR, Postpone,
CallEnter, StateCall, Actions,
@@ -1725,6 +1652,80 @@ loop_actions_timeout(
Q)
end.
+%% Process a reply action
+%%
+loop_actions_reply(
+ P, Debug, S, Q, NextState_NewData,
+ NextEventsR, Hibernate, TimeoutsR, Postpone,
+ CallEnter, StateCall, Actions,
+ From, Reply) ->
+ %%
+ case from(From) of
+ true ->
+ %% No need for a separate ?not_sys_debug clause here
+ %% since the external call to erlang:'!'/2 in reply/2
+ %% will cause swap out of all live registers anyway
+ reply(From, Reply),
+ Debug_1 = ?sys_debug(Debug, P#params.name, {out,Reply,From}),
+ loop_actions_list(
+ P, Debug_1, S, Q, NextState_NewData,
+ NextEventsR, Hibernate, TimeoutsR, Postpone,
+ CallEnter, StateCall, Actions);
+ false ->
+ terminate(
+ error,
+ {bad_action_from_state_function,{reply,From,Reply}},
+ ?STACKTRACE(), P, Debug,
+ S#state{
+ state_data = NextState_NewData,
+ hibernate = Hibernate},
+ Q)
+ end.
+
+%% Process a next_event action
+%%
+loop_actions_next_event(
+ P, Debug, S, Q, NextState_NewData,
+ NextEventsR, Hibernate, TimeoutsR, Postpone,
+ CallEnter, StateCall, Actions, Type, Content) ->
+ case event_type(Type) of
+ true when StateCall ->
+ NextEvent = {Type,Content},
+ case Debug of
+ ?not_sys_debug ->
+ loop_actions_list(
+ P, Debug, S, Q, NextState_NewData,
+ [NextEvent|NextEventsR],
+ Hibernate, TimeoutsR, Postpone,
+ CallEnter, StateCall, Actions);
+ _ ->
+ Name = P#params.name,
+ {State,_Data} = S#state.state_data,
+ Debug_1 =
+ sys_debug(Debug, Name, {in,{Type,Content},State}),
+ loop_actions_list(
+ P, Debug_1, S, Q, NextState_NewData,
+ [NextEvent|NextEventsR],
+ Hibernate, TimeoutsR, Postpone,
+ CallEnter, StateCall, Actions)
+ end;
+ _ ->
+ terminate(
+ error,
+ {if
+ StateCall ->
+ bad_action_from_state_function;
+ true ->
+ bad_state_enter_action_from_state_function
+ end,
+ {next_event,Type,Content}},
+ ?STACKTRACE(), P, Debug,
+ S#state{
+ state_data = NextState_NewData,
+ hibernate = Hibernate},
+ Q)
+ end.
+
%% Do the state transition
%%
loop_state_transition(