diff options
author | Siri Hansen <[email protected]> | 2014-06-11 14:29:19 +0200 |
---|---|---|
committer | Siri Hansen <[email protected]> | 2014-06-11 14:29:19 +0200 |
commit | da42410cb15c0749ea6cf9b6196b81320d8391b6 (patch) | |
tree | 829f5cdb59cf92cdaf381564fe51885644494650 /lib/wx/test/wx_obj_test.erl | |
parent | 5f2b70f205bc64be545b75db5419111aac11291d (diff) | |
parent | 154a057dcbf087deb38b13e97f0a0373e6a72f1d (diff) | |
download | otp-da42410cb15c0749ea6cf9b6196b81320d8391b6.tar.gz otp-da42410cb15c0749ea6cf9b6196b81320d8391b6.tar.bz2 otp-da42410cb15c0749ea6cf9b6196b81320d8391b6.zip |
Merge branch 'siri/sync-stop-gen/OTP-11173'
* siri/sync-stop-gen/OTP-11173:
Add synchronous stop function to wx_object
Fix minor bugs in gen_server and gen_fsm documentation
Update gen_event:stop to be synchronous
Add synchronous stop functions to gen_server and gen_fsm
Add synchronous stop function to proc_lib
Add system message 'terminate'
Remove old code from stdlib/test/sys_sp2.erl
Diffstat (limited to 'lib/wx/test/wx_obj_test.erl')
-rw-r--r-- | lib/wx/test/wx_obj_test.erl | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/lib/wx/test/wx_obj_test.erl b/lib/wx/test/wx_obj_test.erl index f47f2fbc46..6c648c65f8 100644 --- a/lib/wx/test/wx_obj_test.erl +++ b/lib/wx/test/wx_obj_test.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2011-2013. All Rights Reserved. +%% Copyright Ericsson AB 2011-2014. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -18,7 +18,7 @@ -module(wx_obj_test). -include_lib("wx/include/wx.hrl"). --export([start/1, stop/2]). +-export([start/1, stop/1]). %% wx_object callbacks -export([init/1, handle_info/2, terminate/2, code_change/3, handle_call/3, @@ -29,8 +29,8 @@ start(Opts) -> wx_object:start_link(?MODULE, [{parent, self()}| Opts], []). -stop(Object, Fun) -> - wx_object:call(Object, {stop, Fun}). +stop(Object) -> + wx_object:stop(Object). init(Opts) -> Parent = proplists:get_value(parent, Opts), @@ -61,8 +61,6 @@ handle_event(Event, State = #state{parent=Parent}) -> handle_call(What, From, State = #state{user_state=US}) when is_function(What) -> Result = What(US), {reply, {call, Result, From}, State}; -handle_call({stop, Fun}, From, State = #state{user_state=US}) -> - {stop, Fun(US), {stop, From}, State}; handle_call(What, From, State) -> {reply, {call, What, From}, State}. @@ -79,7 +77,13 @@ handle_info(What, State = #state{parent=Pid}) -> Pid ! {info, What}, {noreply, State}. -terminate(What, #state{parent=Pid}) -> +terminate(What, #state{parent=Pid, opts=Opts, user_state=US}) -> + case proplists:get_value(terminate, Opts) of + undefined -> + ok; + Terminate -> + Terminate(US) + end, Pid ! {terminate, What}, ok. |