Skip to content

Commit 531bdab

Browse files
committed
Support GenServer.ex & Supervisor.ex
Carbon copy from upstream, and adapted to gen_server.erl Signed-off-by: Peter M <petermm@gmail.com>
1 parent 13b327d commit 531bdab

File tree

11 files changed

+2278
-5
lines changed

11 files changed

+2278
-5
lines changed

libs/estdlib/src/gen_server.erl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ call(Name, Request, TimeoutMs) when is_atom(Name) ->
440440
end;
441441
call(Pid, Request, TimeoutMs) when is_pid(Pid) ->
442442
MonitorRef = monitor(process, Pid),
443-
Pid ! {'$call', {self(), MonitorRef}, Request},
443+
Pid ! {'$gen_call', {self(), MonitorRef}, Request},
444444
receive
445445
{'DOWN', MonitorRef, process, Pid, {E, []} = _Reason} ->
446446
erlang:exit({E, {?MODULE, ?FUNCTION_NAME, [Pid, Request]}});
@@ -475,7 +475,7 @@ cast(Name, Request) when is_atom(Name) ->
475475
cast(Pid, Request)
476476
end;
477477
cast(Pid, Request) when is_pid(Pid) ->
478-
Pid ! {'$cast', Request},
478+
Pid ! {'$gen_cast', Request},
479479
ok.
480480

481481
%%-----------------------------------------------------------------------------
@@ -510,7 +510,7 @@ loop(Parent, #state{mod = Mod, mod_state = ModState} = State, {continue, Continu
510510
end;
511511
loop(Parent, #state{mod = Mod, mod_state = ModState} = State, Timeout) ->
512512
receive
513-
{'$call', {_Pid, _Ref} = From, Request} ->
513+
{'$gen_call', {_Pid, _Ref} = From, Request} ->
514514
case Mod:handle_call(Request, From, ModState) of
515515
{reply, Reply, NewModState} ->
516516
ok = reply(From, Reply),
@@ -535,7 +535,7 @@ loop(Parent, #state{mod = Mod, mod_state = ModState} = State, Timeout) ->
535535
_ ->
536536
do_terminate(State, {error, unexpected_reply}, ModState)
537537
end;
538-
{'$cast', Request} ->
538+
{'$gen_cast', Request} ->
539539
case Mod:handle_cast(Request, ModState) of
540540
{noreply, NewModState} ->
541541
loop(Parent, State#state{mod_state = NewModState}, infinity);

libs/exavmlib/lib/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,20 @@ set(ELIXIR_MODULES
4040
Enumerable.MapSet
4141
Enumerable.Range
4242
Exception
43+
GenServer
44+
GenServerTest.Stack
45+
GenServerTest.CustomStack
46+
SupervisorTest.Stack
47+
SupervisorTest.Stack.Sup
4348
IO
4449
List
4550
Map
4651
MapSet
4752
Module
4853
Keyword
54+
Supervisor
55+
Supervisor.Default
56+
Supervisor.Spec
4957
Kernel
5058
Process
5159
Protocol.UndefinedError

0 commit comments

Comments
 (0)