From 9d7d1207ff1240b9711f192deb0893c3a044a3d8 Mon Sep 17 00:00:00 2001 From: Siri Hansen Date: Wed, 30 Apr 2014 09:35:06 +0200 Subject: Add synchronous stop functions to gen_server and gen_fsm The functions utilize proc_lib:stop, which in turn utilizes sys:terminate. --- lib/stdlib/doc/src/gen_fsm.xml | 38 +++++++++++++++++++++++++++++++++++++- lib/stdlib/doc/src/gen_server.xml | 39 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 75 insertions(+), 2 deletions(-) (limited to 'lib/stdlib/doc/src') diff --git a/lib/stdlib/doc/src/gen_fsm.xml b/lib/stdlib/doc/src/gen_fsm.xml index 1713367bd8..24468b0e8e 100644 --- a/lib/stdlib/doc/src/gen_fsm.xml +++ b/lib/stdlib/doc/src/gen_fsm.xml @@ -4,7 +4,7 @@
- 19962013 + 19962014 Ericsson AB. All Rights Reserved. @@ -43,8 +43,11 @@
 gen_fsm module                    Callback module
 --------------                    ---------------
+gen_fsm:start
 gen_fsm:start_link                -----> Module:init/1
 
+gen_fsm:stop                      -----> Module:terminate/3
+
 gen_fsm:send_event                -----> Module:StateName/2
 
 gen_fsm:send_all_state_event      -----> Module:handle_event/3
@@ -186,6 +189,39 @@ gen_fsm:sync_send_all_state_event -----> Module:handle_sync_event/4
           for a description of arguments and return values.

+ + stop(FsmRef) -> ok + stop(FsmRef, Reason, Timeout) -> ok + Synchronously stop a generic FSM. + + FsmRef = Name | {Name,Node} | {global,GlobalName} + | {via,Module,ViaName} | pid() +  Node = atom() +  GlobalName = ViaName = term() + Reason = term() + Timeout = int()>0 | infinity + + +

Orders a generic FSM to exit with the given Reason + and waits for it to terminate. The gen_fsm will call + Module:terminate/3 + before exiting.

+

The function returns ok if the generic FSM terminates + with the expected reason. Any other reason than normal, + shutdown, or {shutdown,Term} will cause an + error report to be issued using + error_logger:format/2. + The default Reason is normal.

+

Timeout is an integer greater than zero which + specifies how many milliseconds to wait for the generic FSM + to terminate, or the atom infinity to wait + indefinitely. The default value is infinity. If the + generic FSM has not terminated within the specified time, a + timeout exception is raised.

+

If the process does not exist, a noproc exception + is raised.

+
+
send_event(FsmRef, Event) -> ok Send an event asynchronously to a generic FSM. diff --git a/lib/stdlib/doc/src/gen_server.xml b/lib/stdlib/doc/src/gen_server.xml index 4c83fde237..4bef50245d 100644 --- a/lib/stdlib/doc/src/gen_server.xml +++ b/lib/stdlib/doc/src/gen_server.xml @@ -4,7 +4,7 @@
- 19962013 + 19962014 Ericsson AB. All Rights Reserved. @@ -43,8 +43,11 @@
 gen_server module            Callback module
 -----------------            ---------------
+gen_server:start
 gen_server:start_link -----> Module:init/1
 
+gen_server:stop       -----> Module:terminate/2
+
 gen_server:call
 gen_server:multi_call -----> Module:handle_call/3
 
@@ -183,6 +186,40 @@ gen_server:abcast     -----> Module:handle_cast/2
           for a description of arguments and return values.

+ + stop(ServerRef) -> ok + stop(ServerRef, Reason, Timeout) -> ok + Synchronously stop a generic server. + + ServerRef = Name | {Name,Node} | {global,GlobalName} + | {via,Module,ViaName} | pid() +  Node = atom() +  GlobalName = ViaName = term() + Reason = term() + Timeout = int()>0 | infinity + + +

Orders a generic server to exit with the + given Reason and waits for it to terminate. The + gen_server will call + Module:terminate/2 + before exiting.

+

The function returns ok if the server terminates + with the expected reason. Any other reason than normal, + shutdown, or {shutdown,Term} will cause an + error report to be issued using + error_logger:format/2. + The default Reason is normal.

+

Timeout is an integer greater than zero which + specifies how many milliseconds to wait for the server to + terminate, or the atom infinity to wait + indefinitely. The default value is infinity. If the + server has not terminated within the specified time, a + timeout exception is raised.

+

If the process does not exist, a noproc exception + is raised.

+
+
call(ServerRef, Request) -> Reply call(ServerRef, Request, Timeout) -> Reply -- cgit v1.2.3