aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel/src/rpc.erl
diff options
context:
space:
mode:
authorKostis Sagonas <[email protected]>2010-03-05 09:05:52 +0100
committerBjörn Gustavsson <[email protected]>2010-03-07 13:26:34 +0100
commitda70b2b0eca09f572e3275240ba60f1da6b679c4 (patch)
tree234ff94e9f9e0bd6c85c4e6f51cf2acd644903bd /lib/kernel/src/rpc.erl
parent02112d8dba5b40cd0adb7ecb2b2ed4340594369f (diff)
downloadotp-da70b2b0eca09f572e3275240ba60f1da6b679c4.tar.gz
otp-da70b2b0eca09f572e3275240ba60f1da6b679c4.tar.bz2
otp-da70b2b0eca09f572e3275240ba60f1da6b679c4.zip
kernel: Add types and specs
Diffstat (limited to 'lib/kernel/src/rpc.erl')
-rw-r--r--lib/kernel/src/rpc.erl26
1 files changed, 25 insertions, 1 deletions
diff --git a/lib/kernel/src/rpc.erl b/lib/kernel/src/rpc.erl
index d69f2a12ad..8c0dc65ca7 100644
--- a/lib/kernel/src/rpc.erl
+++ b/lib/kernel/src/rpc.erl
@@ -64,25 +64,41 @@
%%------------------------------------------------------------------------
+-type state() :: gb_tree().
+
+%%------------------------------------------------------------------------
+
%% Remote execution and broadcasting facility
+-spec start() -> {'ok', pid()} | 'ignore' | {'error', term()}.
+
start() ->
gen_server:start({local,?NAME},?MODULE,[],[]).
+-spec start_link() -> {'ok', pid()} | 'ignore' | {'error', term()}.
+
start_link() ->
gen_server:start_link({local,?NAME},?MODULE,[],[]).
+-spec stop() -> term().
+
stop() ->
stop(?NAME).
stop(Rpc) ->
gen_server:call(Rpc, stop, infinity).
--spec init([]) -> {'ok', gb_tree()}.
+-spec init([]) -> {'ok', state()}.
+
init([]) ->
process_flag(trap_exit, true),
{ok, gb_trees:empty()}.
+-spec handle_call(term(), term(), state()) ->
+ {'noreply', state()} |
+ {'reply', term(), state()} |
+ {'stop', 'normal', 'stopped', state()}.
+
handle_call({call, Mod, Fun, Args, Gleader}, To, S) ->
handle_call_call(Mod, Fun, Args, Gleader, To, S);
handle_call({block_call, Mod, Fun, Args, Gleader}, _To, S) ->
@@ -102,6 +118,7 @@ handle_call(stop, _To, S) ->
handle_call(_, _To, S) ->
{noreply, S}. % Ignore !
+-spec handle_cast(term(), state()) -> {'noreply', state()}.
handle_cast({cast, Mod, Fun, Args, Gleader}, S) ->
spawn(
@@ -113,6 +130,7 @@ handle_cast({cast, Mod, Fun, Args, Gleader}, S) ->
handle_cast(_, S) ->
{noreply, S}. % Ignore !
+-spec handle_info(term(), state()) -> {'noreply', state()}.
handle_info({'DOWN', _, process, Caller, Reason}, S) ->
case gb_trees:lookup(Caller, S) of
@@ -160,9 +178,13 @@ handle_info({From, {call,Mod,Fun,Args,Gleader}}, S) ->
handle_info(_, S) ->
{noreply,S}.
+-spec terminate(term(), state()) -> 'ok'.
+
terminate(_, _S) ->
ok.
+-spec code_change(term(), state(), term()) -> {'ok', state()}.
+
code_change(_, S, _) ->
{ok, S}.
@@ -226,6 +248,8 @@ proxy_user_loop() ->
undefined -> proxy_user_loop()
end.
+-spec proxy_user_flush() -> no_return().
+
proxy_user_flush() ->
%% Forward all received messages to 'user'
receive Msg ->