aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaimo Niskanen <[email protected]>2016-03-17 16:05:35 +0100
committerRaimo Niskanen <[email protected]>2016-03-17 16:05:35 +0100
commit2cd331fec3e08799bdd482399e8c969102e1142f (patch)
tree346cacb3a70a36aff97e93d2e72173d8c013c174
parent0eddc557de9b0a996ab42aefd66f3229a06f6675 (diff)
downloadotp-2cd331fec3e08799bdd482399e8c969102e1142f.tar.gz
otp-2cd331fec3e08799bdd482399e8c969102e1142f.tar.bz2
otp-2cd331fec3e08799bdd482399e8c969102e1142f.zip
Change Caller -> From as suggested by Fred Hebert
-rw-r--r--lib/stdlib/doc/src/gen_statem.xml50
-rw-r--r--lib/stdlib/src/gen_statem.erl46
2 files changed, 48 insertions, 48 deletions
diff --git a/lib/stdlib/doc/src/gen_statem.xml b/lib/stdlib/doc/src/gen_statem.xml
index 90d2326954..83f7dc1c8a 100644
--- a/lib/stdlib/doc/src/gen_statem.xml
+++ b/lib/stdlib/doc/src/gen_statem.xml
@@ -253,23 +253,23 @@ init([]) ->
%%% State functions
-off({call,Caller}, push, Data) ->
+off({call,From}, push, Data) ->
%% Go to 'on', increment count and reply
%% that the resulting status is 'on'
- {next_state,on,Data+1,[{reply,Caller,on}]};
+ {next_state,on,Data+1,[{reply,From,on}]};
off(EventType, EventContent, Data) ->
handle_event(EventType, EventContent, Data).
-on({call,Caller}, push, Data) ->
+on({call,From}, push, Data) ->
%% Go to 'off' and reply that the resulting status is 'off'
- {next_state,off,Data,[{reply,Caller,off}]};
+ {next_state,off,Data,[{reply,From,off}]};
on(EventType, EventContent, Data) ->
handle_event(EventType, EventContent, Data).
%% Handle events common to all states
-handle_event({call,Caller}, get_count, Data) ->
+handle_event({call,From}, get_count, Data) ->
%% Reply with the current count
- {keep_state,Data,[{reply,Caller,Data}]};
+ {keep_state,Data,[{reply,From,Data}]};
handle_event(_, _, Data) ->
%% Ignore all other events
{keep_state,Data}.
@@ -315,18 +315,18 @@ init([]) ->
%%% Event handling
-handle_event({call,Caller}, push, off, Data) ->
+handle_event({call,From}, push, off, Data) ->
%% Go to 'on', increment count and reply
%% that the resulting status is 'on'
- {next_state,on,Data+1,[{reply,Caller,on}]};
-handle_event({call,Caller}, push, on, Data) ->
+ {next_state,on,Data+1,[{reply,From,on}]};
+handle_event({call,From}, push, on, Data) ->
%% Go to 'off' and reply that the resulting status is 'off'
- {next_state,off,Data,[{reply,Caller,off}]};
+ {next_state,off,Data,[{reply,From,off}]};
%%
%% Event handling common to all states
-handle_event({call,Caller}, get_count, State, Data) ->
+handle_event({call,From}, get_count, State, Data) ->
%% Reply with the current count
- {next_state,State,Data,[{reply,Caller,Data}]};
+ {next_state,State,Data,[{reply,From,Data}]};
handle_event(_, _, State, Data) ->
%% Ignore all other events
{next_state,State,Data}.
@@ -429,12 +429,12 @@ handle_event(_, _, State, Data) ->
</datatype>
<datatype>
- <name name="caller" />
+ <name name="from" />
<desc>
<p>
Destination to use when replying through for example the
<seealso marker="#type-action">
- action() {reply,Caller,Reply}
+ action() {reply,From,Reply}
</seealso>
to a process that has called the <c>gen_statem</c> server using
<seealso marker="#call/2">call/2</seealso>.
@@ -483,7 +483,7 @@ handle_event(_, _, State, Data) ->
<desc>
<p>
External events are of 3 different type:
- <c>{call,<anno>Caller</anno>}</c>, <c>cast</c> or <c>info</c>.
+ <c>{call,<anno>From</anno>}</c>, <c>cast</c> or <c>info</c>.
<seealso marker="#call/2">Calls</seealso>
(synchronous) and
<seealso marker="#cast/2">casts</seealso>
@@ -739,9 +739,9 @@ handle_event(_, _, State, Data) ->
<p>
Reply to a caller waiting for a reply in
<seealso marker="#call/2"><c>call/2</c></seealso>.
- <c><anno>Caller</anno></c> must be the term from the
+ <c><anno>From</anno></c> must be the term from the
<seealso marker="#type-event_type">
- <c>{call,<anno>Caller</anno>}</c>
+ <c>{call,<anno>From</anno>}</c>
</seealso>
argument to the
<seealso marker="#state_function">state function</seealso>.
@@ -1029,14 +1029,14 @@ handle_event(_, _, State, Data) ->
The <c>gen_statem</c> will call the
<seealso marker="#state_function">state function</seealso> with
<seealso marker="#type-event_type"><c>event_type()</c></seealso>
- <c>{call,Caller}</c> and event content
+ <c>{call,From}</c> and event content
<c><anno>Request</anno></c>.
</p>
<p>
A <c><anno>Reply</anno></c> is generated when a
<seealso marker="#state_function">state function</seealso>
returns with
- <c>{reply,Caller,<anno>Reply</anno>}</c> as one
+ <c>{reply,From,<anno>Reply</anno>}</c> as one
<seealso marker="#type-action"><c>action()</c></seealso>,
and that <c><anno>Reply</anno></c> becomes the return value
of this function.
@@ -1100,13 +1100,13 @@ handle_event(_, _, State, Data) ->
<seealso marker="#state_function">state function</seealso>.
</p>
<p>
- <c><anno>Caller</anno></c> must be the term from the
+ <c><anno>From</anno></c> must be the term from the
<seealso marker="#type-event_type">
- <c>{call,<anno>Caller</anno>}</c>
+ <c>{call,<anno>From</anno>}</c>
</seealso>
argument to the
<seealso marker="#state_function">state function</seealso>.
- <c><anno>Caller</anno></c> and <c><anno>Reply</anno></c>
+ <c><anno>From</anno></c> and <c><anno>Reply</anno></c>
can also be specified using a
<seealso marker="#type-reply_action">
<c>reply_action()</c>
@@ -1340,15 +1340,15 @@ handle_event(_, _, State, Data) ->
</p>
<p>
If <c>EventType</c> is
- <seealso marker="#type-event_type"><c>{call,Caller}</c></seealso>
+ <seealso marker="#type-event_type"><c>{call,From}</c></seealso>
the caller is waiting for a reply. The reply can be sent
from this or from any other
<seealso marker="#state_function">state function</seealso>
- by returning with <c>{reply,Caller,Reply}</c> in
+ by returning with <c>{reply,From,Reply}</c> in
<seealso marker="#type-action">Actions</seealso>, in
<seealso marker="#type-reply_action">Replies</seealso>
or by calling
- <seealso marker="#reply/2"><c>reply(Caller, Reply)</c></seealso>.
+ <seealso marker="#reply/2"><c>reply(From, Reply)</c></seealso>.
</p>
<p>
If this function returns with a next state that
diff --git a/lib/stdlib/src/gen_statem.erl b/lib/stdlib/src/gen_statem.erl
index 92e26bd7ed..82ac5824eb 100644
--- a/lib/stdlib/src/gen_statem.erl
+++ b/lib/stdlib/src/gen_statem.erl
@@ -59,7 +59,7 @@
%%% Interface functions.
%%%==========================================================================
--type caller() ::
+-type from() ::
{To :: pid(), Tag :: term()}. % Reply-to specifier for call
-type state() ::
@@ -71,7 +71,7 @@
-type data() :: term().
-type event_type() ::
- {'call',Caller :: caller()} | 'cast' |
+ {'call',From :: from()} | 'cast' |
'info' | 'timeout' | 'internal'.
-type callback_mode() :: 'state_functions' | 'handle_event_function'.
@@ -125,7 +125,7 @@
EventContent :: term()}.
-type reply_action() ::
{'reply', % Reply to a caller
- Caller :: caller(), Reply :: term()}.
+ From :: from(), Reply :: term()}.
-type state_function_result() ::
{'next_state', % {next_state,NextStateName,NewData,[]}
@@ -253,13 +253,13 @@ callback_mode(CallbackMode) ->
false
end.
%%
-caller({Pid,_}) when is_pid(Pid) ->
+from({Pid,_}) when is_pid(Pid) ->
true;
-caller(_) ->
+from(_) ->
false.
%%
-event_type({call,Caller}) ->
- caller(Caller);
+event_type({call,From}) ->
+ from(From);
event_type(Type) ->
case Type of
cast ->
@@ -378,7 +378,7 @@ cast(ServerRef, Msg) when is_pid(ServerRef) ->
send(ServerRef, wrap_cast(Msg)).
%% Call a state machine (synchronous; a reply is expected) that
-%% arrives with type {call,Caller}
+%% arrives with type {call,From}
-spec call(ServerRef :: server_ref(), Request :: term()) -> Reply :: term().
call(ServerRef, Request) ->
call(ServerRef, Request, infinity).
@@ -437,12 +437,12 @@ call(ServerRef, Request, Timeout) ->
%% Reply from a state machine callback to whom awaits in call/2
-spec reply([reply_action()] | reply_action()) -> ok.
-reply({reply,Caller,Reply}) ->
- reply(Caller, Reply);
+reply({reply,From,Reply}) ->
+ reply(From, Reply);
reply(Replies) when is_list(Replies) ->
replies(Replies).
%%
--spec reply(Caller :: caller(), Reply :: term()) -> ok.
+-spec reply(From :: from(), Reply :: term()) -> ok.
reply({To,Tag}, Reply) when is_pid(To) ->
Msg = {Tag,Reply},
try To ! Msg of
@@ -509,8 +509,8 @@ enter_loop(Module, Opts, CallbackMode, State, Data, Server, Actions) ->
wrap_cast(Event) ->
{'$gen_cast',Event}.
-replies([{reply,Caller,Reply}|Replies]) ->
- reply(Caller, Reply),
+replies([{reply,From,Reply}|Replies]) ->
+ reply(From, Reply),
replies(Replies);
replies([]) ->
ok.
@@ -782,8 +782,8 @@ loop_receive(Parent, Debug, #{timer := Timer} = S) ->
end,
Event =
case Msg of
- {'$gen_call',Caller,Request} ->
- {{call,Caller},Request};
+ {'$gen_call',From,Request} ->
+ {{call,From},Request};
{'$gen_cast',E} ->
{cast,E};
_ ->
@@ -983,10 +983,10 @@ loop_event_actions(
?TERMINATE(
error, {bad_action,Action}, Debug, S, [Event|Events]);
%% Actual actions
- {reply,Caller,Reply} ->
- case caller(Caller) of
+ {reply,From,Reply} ->
+ case from(From) of
true ->
- NewDebug = do_reply(Debug, S, Caller, Reply),
+ NewDebug = do_reply(Debug, S, From, Reply),
loop_event_actions(
Parent, NewDebug, S, Events, Event,
State, NextState, NewData, Actions,
@@ -1101,17 +1101,17 @@ do_reply_then_terminate(Class, Reason, Stacktrace, Debug, S, Q, []) ->
do_reply_then_terminate(
Class, Reason, Stacktrace, Debug, S, Q, [R|Rs]) ->
case R of
- {reply,{_To,_Tag}=Caller,Reply} ->
- NewDebug = do_reply(Debug, S, Caller, Reply),
+ {reply,{_To,_Tag}=From,Reply} ->
+ NewDebug = do_reply(Debug, S, From, Reply),
do_reply_then_terminate(
Class, Reason, Stacktrace, NewDebug, S, Q, Rs);
_ ->
[error,{bad_action,R},?STACKTRACE(),Debug]
end.
-do_reply(Debug, S, Caller, Reply) ->
- reply(Caller, Reply),
- sys_debug(Debug, S, {out,Reply,Caller}).
+do_reply(Debug, S, From, Reply) ->
+ reply(From, Reply),
+ sys_debug(Debug, S, {out,Reply,From}).
terminate(