Skip to content
This repository
Newer
Older
100644 99 lines (81 sloc) 3.517 kb
a6d8e2ef » marc@zoo.local
2009-11-12 Added r1392 from Zotonic svn
1 %% @author Marc Worrell <marc@worrell.nl>
2 %% @copyright 2009 Marc Worrell
3 %%
4 %% @doc
5
6 %% Copyright 2009 Marc Worrell
7 %%
8 %% Licensed under the Apache License, Version 2.0 (the "License");
9 %% you may not use this file except in compliance with the License.
10 %% You may obtain a copy of the License at
11 %%
12 %% http://www.apache.org/licenses/LICENSE-2.0
13 %%
14 %% Unless required by applicable law or agreed to in writing, software
15 %% distributed under the License is distributed on an "AS IS" BASIS,
16 %% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 %% See the License for the specific language governing permissions and
18 %% limitations under the License.
19
20 -module(module_name).
21 -author("Marc Worrell <marc@worrell.nl>").
22 -behaviour(gen_server).
23
24 %% gen_server exports
25 -export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]).
26 -export([start_link/0, start_link/1]).
27
28 %% interface functions
29 -export([
30 ]).
31
32 %%====================================================================
33 %% API
34 %%====================================================================
35 %% @spec start_link() -> {ok,Pid} | ignore | {error,Error}
36 %% @doc Starts the server
37 start_link() ->
38 start_link([]).
39 start_link(Args) when is_list(Args) ->
40 gen_server:start_link({local, ?MODULE}, ?MODULE, Args, []).
41
42 %%====================================================================
43 %% gen_server callbacks
44 %%====================================================================
45
46 %% @spec init(Args) -> {ok, State} |
47 %% {ok, State, Timeout} |
48 %% ignore |
49 %% {stop, Reason}
50 %% @doc Initiates the server.
51 init(_Args) ->
52 {ok, []}.
53
54 %% @spec handle_call(Request, From, State) -> {reply, Reply, State} |
55 %% {reply, Reply, State, Timeout} |
56 %% {noreply, State} |
57 %% {noreply, State, Timeout} |
58 %% {stop, Reason, Reply, State} |
59 %% {stop, Reason, State}
60 %% Description: Handling call messages
61 %% @doc Trap unknown calls
62 handle_call(Message, _From, State) ->
63 {stop, {unknown_call, Message}, State}.
64
65
66 %% @spec handle_cast(Msg, State) -> {noreply, State} |
67 %% {noreply, State, Timeout} |
68 %% {stop, Reason, State}
69 %% @doc Trap unknown casts
70 handle_cast(Message, State) ->
71 {stop, {unknown_cast, Message}, State}.
72
73
74
75 %% @spec handle_info(Info, State) -> {noreply, State} |
76 %% {noreply, State, Timeout} |
77 %% {stop, Reason, State}
78 %% @doc Handling all non call/cast messages
79 handle_info(_Info, State) ->
80 {noreply, State}.
81
82 %% @spec terminate(Reason, State) -> void()
83 %% @doc This function is called by a gen_server when it is about to
84 %% terminate. It should be the opposite of Module:init/1 and do any necessary
85 %% cleaning up. When it returns, the gen_server terminates with Reason.
86 %% The return value is ignored.
87 terminate(_Reason, _State) ->
88 ok.
89
90 %% @spec code_change(OldVsn, State, Extra) -> {ok, NewState}
91 %% @doc Convert process state when code is changed
92
93 code_change(_OldVsn, State, _Extra) ->
94 {ok, State}.
95
96
97 %%====================================================================
98 %% support functions
99 %%====================================================================
100
Something went wrong with that request. Please try again.