From da70b2b0eca09f572e3275240ba60f1da6b679c4 Mon Sep 17 00:00:00 2001 From: Kostis Sagonas Date: Fri, 5 Mar 2010 09:05:52 +0100 Subject: kernel: Add types and specs --- lib/kernel/src/rpc.erl | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'lib/kernel/src/rpc.erl') 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 -> -- cgit v1.2.3