Permalink
Browse files

Clean up finsrv template for gen_server modules

  • Loading branch information...
1 parent cd51541 commit fa3168e3d8f78e719fc07113872ae426044f9038 @mbbx6spp committed Jun 12, 2011
Showing with 11 additions and 23 deletions.
  1. +11 −23 finsrv.erl
View
@@ -14,65 +14,53 @@
-export([code_change/3]).
-export([stop/0, terminate/2]).
--ifdef(TEST).
--compile(export_all).
--endif.
-
% TODO: If unnamed server, remove definition below.
-define(SERVER, ?MODULE).
%%%.
%%%' PUBLIC API
%% @doc starts gen_server implementation and caller links to the process too.
-%% @spec start_link() -> {ok, Pid} | ignore | {error, Error}
-%% where
-%% Pid = pid(),
-%% Error = {already_started, Pid} | term()
+-spec start_link() -> {ok, Pid} | ignore | {error, Error}
+ when
+ Pid :: pid(),
+ Error :: {already_started, Pid} | term().
start_link() ->
% TODO: decide whether to name gen_server callback implementation or not.
% gen_server:start_link(?MODULE, [], []). % for unnamed gen_server
gen_server:start_link({local, ?SERVER}, ?MODULE, [], []).
-%% @doc start gen_server implementation without caller link
-%% @spec start() -> {ok, Pid} | ignore | {error, Error}
-%% where
-%% Pid = pid(),
-%% Error = {already_started, Pid} | term()
-start() ->
- gen_server:start({local, ?SERVER}, ?MODULE, [], []).
-
%% @doc stops gen_server implementation process
-%% @spec stop() -> ok
+-spec stop() -> ok.
stop() ->
gen_server:cast(?SERVER, stop).
% TODO: add more public API here...
%%%.
%%%' CALLBACKS
-%% @private
+%% @callback gen_server
init(State) ->
{ok, State}.
-%% @private
+%% @callback gen_server
handle_call(_Req, _From, State) ->
{reply, State}.
-%% @private
+%% @callback gen_server
handle_cast(stop, State) ->
{stop, normal, State};
handle_cast(_Req, State) ->
{noreply, State}.
-%% @private
+%% @callback gen_server
handle_info(_Info, State) ->
{noreply, State}.
-%% @private
+%% @callback gen_server
code_change(_OldVsn, State, _Extra) ->
{ok, State}.
-%% @private
+%% @callback gen_server
terminate(normal, _State) ->
ok;
terminate(shutdown, _State) ->

0 comments on commit fa3168e

Please sign in to comment.