diff options
author | Erlang/OTP <otp@erlang.org> | 2010-03-09 06:07:55 +0000 |
---|---|---|
committer | Erlang/OTP <otp@erlang.org> | 2010-03-09 06:07:55 +0000 |
commit | 36dab22b34d33e1fb8f22af9131d2b33aa97bbd5 (patch) | |
tree | ccd9f079beb8413f4b8889dae6827586c175da51 /lib/kernel/src/rpc.erl | |
parent | 02112d8dba5b40cd0adb7ecb2b2ed4340594369f (diff) | |
parent | 8fef4ffec7245102407ccf73afb5c5c4a42a4ee3 (diff) | |
download | otp-36dab22b34d33e1fb8f22af9131d2b33aa97bbd5.tar.gz otp-36dab22b34d33e1fb8f22af9131d2b33aa97bbd5.tar.bz2 otp-36dab22b34d33e1fb8f22af9131d2b33aa97bbd5.zip |
Merge branch 'ks/types' into dev
* ks/types:
file.hrl: Move out type declarations
kernel: Add types and specs
OTP-8494 ks/types
Diffstat (limited to 'lib/kernel/src/rpc.erl')
-rw-r--r-- | lib/kernel/src/rpc.erl | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/lib/kernel/src/rpc.erl b/lib/kernel/src/rpc.erl index d69f2a12ad..43a987f313 100644 --- a/lib/kernel/src/rpc.erl +++ b/lib/kernel/src/rpc.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 1996-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 1996-2010. 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 %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% -module(rpc). @@ -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 -> |