Last active
October 30, 2022 09:22
-
-
Save yowcow/5232cf33f802cf5144852b65971fa2c5 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
-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