aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorjuhlig <[email protected]>2018-04-23 17:23:33 +0200
committerLoïc Hoguin <[email protected]>2018-04-25 18:37:58 +0200
commit22b77abb905cd12af7e1b3d5f1d6f8f927da18df (patch)
tree51a3c122401361756b1f0bbded2a3650a9a63fe6 /plugins
parentb20df2d7fb690181d10393c97d6103bf2fd0aa86 (diff)
downloaderlang.mk-22b77abb905cd12af7e1b3d5f1d6f8f927da18df.tar.gz
erlang.mk-22b77abb905cd12af7e1b3d5f1d6f8f927da18df.tar.bz2
erlang.mk-22b77abb905cd12af7e1b3d5f1d6f8f927da18df.zip
Add gen_statem template
[skip ci]
Diffstat (limited to 'plugins')
-rw-r--r--plugins/bootstrap.mk45
1 files changed, 45 insertions, 0 deletions
diff --git a/plugins/bootstrap.mk b/plugins/bootstrap.mk
index 8e8b1b1..8ba8b08 100644
--- a/plugins/bootstrap.mk
+++ b/plugins/bootstrap.mk
@@ -252,6 +252,51 @@ code_change(_OldVsn, StateName, StateData, _Extra) ->
{ok, StateName, StateData}.
endef
+define tpl_gen_statem
+-module($(n)).
+-behaviour(gen_statem).
+
+%% API.
+-export([start_link/0]).
+
+%% gen_statem.
+-export([callback_mode/0]).
+-export([init/1]).
+-export([state_name/3]).
+-export([handle_event/4]).
+-export([terminate/3]).
+-export([code_change/4]).
+
+-record(state, {
+}).
+
+%% API.
+
+-spec start_link() -> {ok, pid()}.
+start_link() ->
+ gen_statem:start_link(?MODULE, [], []).
+
+%% gen_statem.
+
+callback_mode() ->
+ state_functions.
+
+init([]) ->
+ {ok, state_name, #state{}}.
+
+state_name(_EventType, _EventData, StateData) ->
+ {next_state, state_name, StateData}.
+
+handle_event(_EventType, _EventData, StateName, StateData) ->
+ {next_state, StateName, StateData}.
+
+terminate(_Reason, _StateName, _StateData) ->
+ ok.
+
+code_change(_OldVsn, StateName, StateData, _Extra) ->
+ {ok, StateName, StateData}.
+endef
+
define tpl_cowboy_loop
-module($(n)).
-behaviour(cowboy_loop_handler).