Created
October 11, 2018 18:47
-
-
Save Laymer/d2c7f2493d7804c5a058b325026da6ef 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
%%%------------------------------------------------------------------- | |
%% @author Igor Kopestenski <i.kopest@gmail.com> | |
%% [https://github.com/Laymer/GrispLasp/] | |
%% @doc This is a <em>gen_server</em> template module. | |
%% @end | |
%%%------------------------------------------------------------------- | |
-module(gen_server_template). | |
-behaviour(gen_server). | |
-include("header.hrl"). | |
%% API | |
-export([start_link/0]). | |
%% Gen Server Callbacks | |
-export([init/1, | |
handle_call/3, | |
handle_cast/2, | |
handle_info/2, | |
handle_continue/2, | |
terminate/2, | |
code_change/3]). | |
%%==================================================================== | |
%% Macros | |
%%==================================================================== | |
-define(MACRO_TEMPLATE(X), {X} ). | |
%%==================================================================== | |
%% Records | |
%%==================================================================== | |
-record(state, {}). | |
%%==================================================================== | |
%% API | |
%%==================================================================== | |
start_link() -> | |
gen_server:start_link({local, ?MODULE}, ?MODULE, [], []). | |
%%==================================================================== | |
%% Gen Server Callbacks | |
%%==================================================================== | |
init([]) -> | |
{ok, #state{}}. | |
%%-------------------------------------------------------------------- | |
handle_call(_Request, _From, State) -> | |
{reply, ignored, State}. | |
%%-------------------------------------------------------------------- | |
handle_cast(_Msg, State) -> | |
{noreply, State}. | |
%%-------------------------------------------------------------------- | |
handle_info(_Info, State) -> | |
{noreply, State}. | |
%%-------------------------------------------------------------------- | |
%% This function is called by a gen_server process | |
%% whenever a previous callback returns {continue, Continue}. | |
%% handle_continue/2 is invoked immediately after the previous callback, | |
%% which makes it useful for performing work after initialization | |
%% or for splitting the work in a callback in multiple steps, | |
%% updating the process state along the way. | |
%%-------------------------------------------------------------------- | |
handle_continue(Continue, State) -> | |
% {noreply,NewState} | {noreply,NewState,Timeout} | |
% | {noreply,NewState,hibernate} | |
% | {noreply,NewState,{continue,Continue}} | |
% | {stop,Reason,NewState} | |
{noreply, State}. | |
%%-------------------------------------------------------------------- | |
terminate(_Reason, _State) -> | |
ok. | |
%%-------------------------------------------------------------------- | |
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