Created
March 24, 2010 23:47
-
-
Save jkvor/342971 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(module_name). | |
-behaviour(gen_server). | |
%% gen_server callbacks | |
-export([start_link/0, init/1, handle_call/3, handle_cast/2, | |
handle_info/2, terminate/2, code_change/3]). | |
%% API functions | |
start_link() -> | |
gen_server:start_link({local, ?MODULE}, ?MODULE, [], []). | |
%%==================================================================== | |
%% gen_server callbacks | |
%%==================================================================== | |
%%-------------------------------------------------------------------- | |
%% Function: init(Args) -> {ok, State} | | |
%% {ok, State, Timeout} | | |
%% ignore | | |
%% {stop, Reason} | |
%% Description: Initiates the server | |
%% @hidden | |
%%-------------------------------------------------------------------- | |
init([]) -> | |
{ok,[]}. | |
%%-------------------------------------------------------------------- | |
%% Function: %% handle_call(Request, From, State) -> {reply, Reply, State} | | |
%% {reply, Reply, State, Timeout} | | |
%% {noreply, State} | | |
%% {noreply, State, Timeout} | | |
%% {stop, Reason, Reply, State} | | |
%% {stop, Reason, State} | |
%% Description: Handling call messages | |
%% @hidden | |
%%-------------------------------------------------------------------- | |
handle_call(_Msg, _From, State) -> {reply, {error, invalid_call}, State}. | |
%%-------------------------------------------------------------------- | |
%% Function: handle_cast(Msg, State) -> {noreply, State} | | |
%% {noreply, State, Timeout} | | |
%% {stop, Reason, State} | |
%% Description: Handling cast messages | |
%% @hidden | |
%%-------------------------------------------------------------------- | |
handle_cast(_Msg, State) -> {noreply, State}. | |
%%-------------------------------------------------------------------- | |
%% Function: handle_info(Info, State) -> {noreply, State} | | |
%% {noreply, State, Timeout} | | |
%% {stop, Reason, State} | |
%% Description: Handling all non call/cast messages | |
%% @hidden | |
%%-------------------------------------------------------------------- | |
handle_info(_Info, State) -> {noreply, State}. | |
%%-------------------------------------------------------------------- | |
%% Function: terminate(Reason, State) -> void() | |
%% Description: This function is called by a gen_server when it is about to | |
%% terminate. It should be the opposite of Module:init/1 and do any necessary | |
%% cleaning up. When it returns, the gen_server terminates with Reason. | |
%% The return value is ignored. | |
%% @hidden | |
%%-------------------------------------------------------------------- | |
terminate(_Reason, _State) -> | |
ok. | |
%%-------------------------------------------------------------------- | |
%% Func: code_change(OldVsn, State, Extra) -> {ok, NewState} | |
%% Description: Convert process state when code is changed | |
%% @hidden | |
%%-------------------------------------------------------------------- | |
code_change(_OldVsn, State, _Extra) -> {ok, State}. | |
%%-------------------------------------------------------------------- | |
%%% Internal functions | |
%%-------------------------------------------------------------------- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment