Skip to content

Instantly share code, notes, and snippets.

@yowcow
Last active October 30, 2022 09:22
Show Gist options
  • Save yowcow/5232cf33f802cf5144852b65971fa2c5 to your computer and use it in GitHub Desktop.
Save yowcow/5232cf33f802cf5144852b65971fa2c5 to your computer and use it in GitHub Desktop.
-module(myproc).
-include_lib("kernel/include/logger.hrl").
-export([
start_link/0
]).
%%
%% {ok, Pid} = myproc:start_link()
%% Pid ! info_message
%% gen_server:cast(Pid, cast_message)
%% gen_server:call(Pid, call_message)
%%
start_link() ->
{ok, spawn_link(fun run/0)}.
run() ->
receive
{'$gen_cast', Req} ->
?LOG_ALERT("handle cast: ~p", [Req]),
ok;
{'$gen_call', {Pid, From}, Req} ->
?LOG_ALERT("handle call: ~p, ~p, ~p", [Pid, From, Req]),
Pid ! {From, 'ok?'},
ok;
Req ->
?LOG_ALERT("handle info: ~p", [Req]),
ok
end,
run().
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment