Skip to content

Commit

Permalink
Basic gen_server
Browse files Browse the repository at this point in the history
  • Loading branch information
Justin Wood committed Oct 22, 2018
1 parent f779111 commit fe14348
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
1 change: 1 addition & 0 deletions rebar.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[].
42 changes: 42 additions & 0 deletions src/havoc.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
%%%-------------------------------------------------------------------
%% @doc havoc
%% @end
%%%-------------------------------------------------------------------

-module(havoc).

-behaviour(gen_server).

%% API
-export([start_link/0]).

%% GenServer callbacks
-export([init/1, handle_call/3, handle_cast/2, handle_info/2]).

-define(SERVER, ?MODULE).

%%====================================================================
%% API functions
%%====================================================================
start_link() ->
gen_server:start_link({local, ?SERVER}, ?MODULE, ok, []).

%%====================================================================
%% GenServer callbacks
%%====================================================================

init(ok) ->
{ok, ok}.

handle_call(_Msg, _From, State) ->
{noreply, State}.

handle_cast(_Msg, State) ->
{noreply, State}.

handle_info(_Msg, State) ->
{noreply, State}.

%%====================================================================
%% Internal functions
%%====================================================================
3 changes: 2 additions & 1 deletion src/havoc_sup.erl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ start_link() ->
%% Before OTP 18 tuples must be used to specify a child. e.g.
%% Child :: {Id,StartFunc,Restart,Shutdown,Type,Modules}
init([]) ->
{ok, { {one_for_all, 0, 1}, []} }.
Havoc = #{id => havoc, start => {havoc, start_link, []}},
{ok, { {one_for_all, 0, 1}, [Havoc]} }.

%%====================================================================
%% Internal functions
Expand Down

0 comments on commit fe14348

Please sign in to comment.