diff options
author | Raimo Niskanen <[email protected]> | 2016-02-29 11:36:27 +0100 |
---|---|---|
committer | Raimo Niskanen <[email protected]> | 2016-02-29 11:36:27 +0100 |
commit | e660572b020da58c89149c7f052c7127cc0263cb (patch) | |
tree | b4d3c27ec17605a06f7e0b72e05248957b7bebe7 /lib/stdlib/test/gen_statem_SUITE.erl | |
parent | c2b8e6cdbc884e93cabe78e9fc9dcc040eb828eb (diff) | |
download | otp-e660572b020da58c89149c7f052c7127cc0263cb.tar.gz otp-e660572b020da58c89149c7f052c7127cc0263cb.tar.bz2 otp-e660572b020da58c89149c7f052c7127cc0263cb.zip |
Remove the remove_event action and all alike
Removing events from the internal queues is not necessary with
the choosen semantics of the event queue vs. hibernate.
In an early implementation it was possible by combining
hibernate with e.g. postpone to get an event in the queue
that you would not see before processing the postponed event,
and therefore should you decide to cancel a timer it was
essential to be able to remove that unseen event from the queue.
With the choosen semantics you will have to postpone or generate
an event for it to be in the event queue, and if you e.g. postpone
a timeout event and then cancel the timer it is your mistake.
You have seen the event and should know better than to try to
cancel the timer.
So, the actions: remove_event, cancel_timer, demonitor and unlink
are now removed.
There have also been some cleanup of the timer handling code.
Diffstat (limited to 'lib/stdlib/test/gen_statem_SUITE.erl')
-rw-r--r-- | lib/stdlib/test/gen_statem_SUITE.erl | 35 |
1 files changed, 14 insertions, 21 deletions
diff --git a/lib/stdlib/test/gen_statem_SUITE.erl b/lib/stdlib/test/gen_statem_SUITE.erl index 268b45a0e7..38aab752b8 100644 --- a/lib/stdlib/test/gen_statem_SUITE.erl +++ b/lib/stdlib/test/gen_statem_SUITE.erl @@ -1210,29 +1210,22 @@ idle(Type, Content, Data) -> end. timeout(timeout, idle, {From,Time}) -> - TRef2 = erlang:start_timer(Time, self(), ok), - TRefC1 = erlang:start_timer(Time, self(), cancel1), - TRefC2 = erlang:start_timer(Time, self(), cancel2), - {next_state,timeout2,{From,Time,TRef2}, - [{cancel_timer, TRefC1}, - {next_event,internal,{cancel_timer,TRefC2}}]}; -timeout(_, _, Data) -> - {keep_state,Data}. - -timeout2( - internal, {cancel_timer,TRefC2}, {From,Time,TRef2}) -> - Time4 = Time * 4, - receive after Time4 -> ok end, - {next_state,timeout3,{From,TRef2}, - [{cancel_timer,TRefC2}]}; -timeout2(_, _, Data) -> - {keep_state,Data}. - -timeout3(info, {timeout,TRef2,Result}, {From,TRef2}) -> + TRef = erlang:start_timer(Time, self(), ok), + {next_state,timeout2,{From,TRef}, + [{timeout,1,should_be_cancelled}, + postpone]}; % Should cancel state timeout +timeout(_, _, _) -> + keep_state_and_data. + +timeout2(timeout, idle, _) -> + keep_state_and_data; +timeout2(timeout, Reason, _) -> + {stop,Reason}; +timeout2(info, {timeout,TRef,Result}, {From,TRef}) -> gen_statem:reply([{reply,From,Result}]), {next_state,idle,state}; -timeout3(_, _, Data) -> - {keep_state,Data}. +timeout2(_, _, _) -> + {keep_state_and_data,[]}. wfor_conf({call,From}, confirm, Data) -> {next_state,connected,Data, |