aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel/src/file_server.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/file_server.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/file_server.erl')
-rw-r--r--lib/kernel/src/file_server.erl23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/kernel/src/file_server.erl b/lib/kernel/src/file_server.erl
index 74f2fb94a9..665e0e3196 100644
--- a/lib/kernel/src/file_server.erl
+++ b/lib/kernel/src/file_server.erl
@@ -62,6 +62,8 @@ stop() ->
%%% Callback functions from gen_server
%%%----------------------------------------------------------------------
+-type state() :: port(). % Internal type
+
%%----------------------------------------------------------------------
%% Func: init/1
%% Returns: {ok, State} |
@@ -69,6 +71,9 @@ stop() ->
%% ignore |
%% {stop, Reason}
%%----------------------------------------------------------------------
+
+-spec init([]) -> {'ok', state()} | {'stop', term()}.
+
init([]) ->
process_flag(trap_exit, true),
case ?PRIM_FILE:start() of
@@ -88,6 +93,12 @@ init([]) ->
%% {stop, Reason, Reply, State} | (terminate/2 is called)
%% {stop, Reason, State} (terminate/2 is called)
%%----------------------------------------------------------------------
+
+-spec handle_call(term(), term(), state()) ->
+ {'noreply', state()} |
+ {'reply', 'eof' | 'ok' | {'error', term()} | {'ok', term()}, state()} |
+ {'stop', 'normal', 'stopped', state()}.
+
handle_call({open, Name, ModeList}, {Pid, _Tag} = _From, Handle)
when is_list(ModeList) ->
Child = ?FILE_IO_SERVER:start_link(Pid, Name, ModeList),
@@ -190,6 +201,9 @@ handle_call(Request, From, Handle) ->
%% {noreply, State, Timeout} |
%% {stop, Reason, State} (terminate/2 is called)
%%----------------------------------------------------------------------
+
+-spec handle_cast(term(), state()) -> {'noreply', state()}.
+
handle_cast(Msg, State) ->
error_logger:error_msg("handle_cast(~p, _)", [Msg]),
{noreply, State}.
@@ -201,6 +215,9 @@ handle_cast(Msg, State) ->
%% {stop, Reason, State} (terminate/2 is called)
%%----------------------------------------------------------------------
+-spec handle_info(term(), state()) ->
+ {'noreply', state()} | {'stop', 'normal', state()}.
+
handle_info({'EXIT', Pid, _Reason}, Handle) when is_pid(Pid) ->
ets:delete(?FILE_IO_SERVER_TABLE, Pid),
{noreply, Handle};
@@ -219,6 +236,9 @@ handle_info(Info, State) ->
%% Purpose: Shutdown the server
%% Returns: any (ignored by gen_server)
%%----------------------------------------------------------------------
+
+-spec terminate(term(), state()) -> 'ok'.
+
terminate(_Reason, Handle) ->
?PRIM_FILE:stop(Handle).
@@ -227,6 +247,9 @@ terminate(_Reason, Handle) ->
%% Purpose: Convert process state when code is changed
%% Returns: {ok, NewState}
%%----------------------------------------------------------------------
+
+-spec code_change(term(), state(), term()) -> {'ok', state()}.
+
code_change(_OldVsn, State, _Extra) ->
{ok, State}.