aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/src/gen_statem.erl
diff options
context:
space:
mode:
authorRaimo Niskanen <[email protected]>2016-04-12 14:30:02 +0200
committerRaimo Niskanen <[email protected]>2016-04-12 14:30:32 +0200
commit9db6054d674969fef314bf8676b6f9b583af3bef (patch)
tree3dbd72061da3fedb418ab714c13fe767dcd843a8 /lib/stdlib/src/gen_statem.erl
parent6bf2768c6836440634019d69231534ed69fcf982 (diff)
downloadotp-9db6054d674969fef314bf8676b6f9b583af3bef.tar.gz
otp-9db6054d674969fef314bf8676b6f9b583af3bef.tar.bz2
otp-9db6054d674969fef314bf8676b6f9b583af3bef.zip
Fix missing short forms for event timeout
Diffstat (limited to 'lib/stdlib/src/gen_statem.erl')
-rw-r--r--lib/stdlib/src/gen_statem.erl75
1 files changed, 43 insertions, 32 deletions
diff --git a/lib/stdlib/src/gen_statem.erl b/lib/stdlib/src/gen_statem.erl
index 9c1e126507..b3a149a569 100644
--- a/lib/stdlib/src/gen_statem.erl
+++ b/lib/stdlib/src/gen_statem.erl
@@ -942,12 +942,32 @@ loop_event_actions(
State, NextState, NewData, [Action|Actions],
Postpone, Hibernate, Timeout, NextEvents) ->
case Action of
+ %% Actual actions
+ {reply,From,Reply} ->
+ case from(From) of
+ true ->
+ NewDebug = do_reply(Debug, S, From, Reply),
+ loop_event_actions(
+ Parent, NewDebug, S, Events, Event,
+ State, NextState, NewData, Actions,
+ Postpone, Hibernate, Timeout, NextEvents);
+ false ->
+ ?TERMINATE(
+ error, {bad_action,Action}, Debug, S, [Event|Events])
+ end;
+ {next_event,Type,Content} ->
+ case event_type(Type) of
+ true ->
+ loop_event_actions(
+ Parent, Debug, S, Events, Event,
+ State, NextState, NewData, Actions,
+ Postpone, Hibernate, Timeout,
+ [{Type,Content}|NextEvents]);
+ false ->
+ ?TERMINATE(
+ error, {bad_action,Action}, Debug, S, [Event|Events])
+ end;
%% Actions that set options
- postpone ->
- loop_event_actions(
- Parent, Debug, S, Events, Event,
- State, NextState, NewData, Actions,
- true, Hibernate, Timeout, NextEvents);
{postpone,NewPostpone} when is_boolean(NewPostpone) ->
loop_event_actions(
Parent, Debug, S, Events, Event,
@@ -956,11 +976,11 @@ loop_event_actions(
{postpone,_} ->
?TERMINATE(
error, {bad_action,Action}, Debug, S, [Event|Events]);
- hibernate ->
+ postpone ->
loop_event_actions(
Parent, Debug, S, Events, Event,
State, NextState, NewData, Actions,
- Postpone, true, Timeout, NextEvents);
+ true, Hibernate, Timeout, NextEvents);
{hibernate,NewHibernate} when is_boolean(NewHibernate) ->
loop_event_actions(
Parent, Debug, S, Events, Event,
@@ -969,6 +989,11 @@ loop_event_actions(
{hibernate,_} ->
?TERMINATE(
error, {bad_action,Action}, Debug, S, [Event|Events]);
+ hibernate ->
+ loop_event_actions(
+ Parent, Debug, S, Events, Event,
+ State, NextState, NewData, Actions,
+ Postpone, true, Timeout, NextEvents);
{timeout,infinity,_} -> % Clear timer - it will never trigger
loop_event_actions(
Parent, Debug, S, Events, Event,
@@ -982,31 +1007,17 @@ loop_event_actions(
{timeout,_,_} ->
?TERMINATE(
error, {bad_action,Action}, Debug, S, [Event|Events]);
- %% Actual actions
- {reply,From,Reply} ->
- case from(From) of
- true ->
- NewDebug = do_reply(Debug, S, From, Reply),
- loop_event_actions(
- Parent, NewDebug, S, Events, Event,
- State, NextState, NewData, Actions,
- Postpone, Hibernate, Timeout, NextEvents);
- false ->
- ?TERMINATE(
- error, {bad_action,Action}, Debug, S, [Event|Events])
- end;
- {next_event,Type,Content} ->
- case event_type(Type) of
- true ->
- loop_event_actions(
- Parent, Debug, S, Events, Event,
- State, NextState, NewData, Actions,
- Postpone, Hibernate, Timeout,
- [{Type,Content}|NextEvents]);
- false ->
- ?TERMINATE(
- error, {bad_action,Action}, Debug, S, [Event|Events])
- end;
+ infinity -> % Clear timer - it will never trigger
+ loop_event_actions(
+ Parent, Debug, S, Events, Event,
+ State, NextState, NewData, Actions,
+ Postpone, Hibernate, undefined, NextEvents);
+ Time when is_integer(Time), Time >= 0 ->
+ NewTimeout = {timeout,Time,Time},
+ loop_event_actions(
+ Parent, Debug, S, Events, Event,
+ State, NextState, NewData, Actions,
+ Postpone, Hibernate, NewTimeout, NextEvents);
_ ->
?TERMINATE(
error, {bad_action,Action}, Debug, S, [Event|Events])