From 6c3d24ccbc597e6d31db1f559470cc59585fdf52 Mon Sep 17 00:00:00 2001
From: Siri Hansen
This function orders the process to terminate with the
+ given
Orders the process to exit with the given
The function returns
If the call times out, a
If the process does not exist, a
The implementation of this function is based on the
+
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 thannormal , +shutdown , or{shutdown,Term} will cause an + error report to be issued using +error_logger:format/2 . + The defaultReason isnormal .+
Timeout is an integer greater than zero which + specifies how many milliseconds to wait for the generic FSM + to terminate, or the atominfinity to wait + indefinitely. The default value isinfinity . 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 @@- 1996 2013 +1996 2014 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 thannormal , +shutdown , or{shutdown,Term} will cause an + error report to be issued using +error_logger:format/2 . + The defaultReason isnormal .+
Timeout is an integer greater than zero which + specifies how many milliseconds to wait for the server to + terminate, or the atominfinity to wait + indefinitely. The default value isinfinity . 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 From f979493bfa777e61d4da1460982370c0cecc1ef3 Mon Sep 17 00:00:00 2001 From: Siri HansenDate: Tue, 6 May 2014 11:50:45 +0200 Subject: Update gen_event:stop to be synchronous This function now uses proc_lib:stop, which guarantees that the process is terminated before the function return. --- lib/stdlib/doc/src/gen_event.xml | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) (limited to 'lib/stdlib/doc/src') diff --git a/lib/stdlib/doc/src/gen_event.xml b/lib/stdlib/doc/src/gen_event.xml index b9dfff833e..5c96d6e576 100644 --- a/lib/stdlib/doc/src/gen_event.xml +++ b/lib/stdlib/doc/src/gen_event.xml @@ -4,7 +4,7 @@ - 1996 2013 +1996 2014 Ericsson AB. All Rights Reserved. @@ -44,6 +44,7 @@ gen_event module Callback module ---------------- --------------- +gen_event:start gen_event:start_link -----> - gen_event:add_handler @@ -177,7 +178,7 @@ gen_event:stop -----> Module:terminate/2add_handler(EventMgrRef, Handler, Args) -> Result Add an event handler to a generic event manager. - EventMgr = Name | {Name,Node} | {global,GlobalName} + EventMgrRef = Name | {Name,Node} | {global,GlobalName} | {via,Module,ViaName} | pid() Name = Node = atom() GlobalName = ViaName = term() @@ -223,7 +224,7 @@ gen_event:stop -----> Module:terminate/2add_sup_handler(EventMgrRef, Handler, Args) -> Result Add a supervised event handler to a generic event manager. - EventMgr = Name | {Name,Node} | {global,GlobalName} + EventMgrRef = Name | {Name,Node} | {global,GlobalName} | {via,Module,ViaName} | pid() Name = Node = atom() GlobalName = ViaName = term() @@ -456,19 +457,37 @@ gen_event:stop -----> Module:terminate/2-- cgit v1.2.3 From 90b779ed59c734b31d26f0b18571a531923ce9f5 Mon Sep 17 00:00:00 2001 From: Siri Hansen stop(EventMgrRef) -> ok +stop(EventMgrRef, Reason, Timeout) -> ok Terminate a generic event manager. EventMgrRef = Name | {Name,Node} | {global,GlobalName} | {via,Module,ViaName} | pid() Name = Node = atom() GlobalName = ViaName = term() +Reason = term() +Timeout = int()>0 | infinity - Terminates the event manager
-EventMgrRef . Before - terminating, the event manager will call -Module:terminate(stop,...) for each installed event - handler.See
+add_handler/3 for a description of the argument.Orders the event manager
+EventMgrRef to exit with + the givenReason and waits for it to + terminate. Before terminating, the gen_event will call +Module:terminate(stop,...) + for each installed event handler.The function returns
+ok if the event manager terminates + with the expected reason. Any other reason thannormal , +shutdown , or{shutdown,Term} will cause an + error report to be issued using +error_logger:format/2 . + The defaultReason isnormal .+
Timeout is an integer greater than zero which + specifies how many milliseconds to wait for the event manager to + terminate, or the atominfinity to wait + indefinitely. The default value isinfinity . If the + event manager has not terminated within the specified time, a +timeout exception is raised.If the process does not exist, a
+noproc exception + is raised.See
add_handler/3 for a description ofEventMgrRef .Date: Wed, 7 May 2014 11:47:40 +0200 Subject: Fix minor bugs in gen_server and gen_fsm documentation These are probably old copy-and-paste bugs from initial version of this document. --- lib/stdlib/doc/src/gen_fsm.xml | 10 ++++++---- lib/stdlib/doc/src/gen_server.xml | 2 +- 2 files changed, 7 insertions(+), 5 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 24468b0e8e..b1bba3eff0 100644 --- a/lib/stdlib/doc/src/gen_fsm.xml +++ b/lib/stdlib/doc/src/gen_fsm.xml @@ -118,7 +118,7 @@ gen_fsm:sync_send_all_state_event -----> Module:handle_sync_event/4 If FsmName={global,GlobalName} , the gen_fsm is registered globally asGlobalName usingglobal:register_name/2 . - IfEventMgrName={via,Module,ViaName} , the event manager will + IfFsmName={via,Module,ViaName} , the gen_fsm will register with the registry represented byModule . TheModule callback should export the functionsregister_name/2 ,unregister_name/1 , @@ -246,7 +246,7 @@ gen_fsm:sync_send_all_state_event -----> Module:handle_sync_event/4 registered at another node, or- -
{global,GlobalName} , if the gen_fsm is globally registered.{via,Module,ViaName} , if the event manager is registered +{via,Module,ViaName} , if the gen_fsm is registered through an alternative process registry.
Event is an arbitrary term which is passed as one of @@ -564,7 +564,8 @@ gen_fsm:sync_send_all_state_event -----> Module:handle_sync_event/4Module:init/1 for a description ofTimeout andhibernate .If the function returns
+{stop,Reason,NewStateData} , the gen_fsm will call -Module:terminate(Reason,NewStateData) and terminate.Module:terminate(Reason,StateName,NewStateData) and + terminate.@@ -650,7 +651,8 @@ gen_fsm:sync_send_all_state_event -----> Module:handle_sync_event/4 {stop,Reason,NewStateData} , any reply toFrom must be given explicitly usinggen_fsm:reply/2 . The gen_fsm will then call -Module:terminate(Reason,NewStateData) and terminate. +Module:terminate(Reason,StateName,NewStateData) and + terminate.diff --git a/lib/stdlib/doc/src/gen_server.xml b/lib/stdlib/doc/src/gen_server.xml index 4bef50245d..a915e567a5 100644 --- a/lib/stdlib/doc/src/gen_server.xml +++ b/lib/stdlib/doc/src/gen_server.xml @@ -116,7 +116,7 @@ gen_server:abcast -----> Module:handle_cast/2 registered globally as GlobalName usingglobal:register_name/2 . If no name is provided, the gen_server is not registered. - IfEventMgrName={via,Module,ViaName} , the event manager will + IfServerName={via,Module,ViaName} , the gen_server will register with the registry represented byModule . TheModule callback should export the functionsregister_name/2 ,unregister_name/1 , -- cgit v1.2.3