test(refactor): no need for monitor

the janitor is already linked to the parent
This commit is contained in:
Thales Macedo Garitezi 2022-12-14 10:39:58 -03:00
parent a0e11f75d9
commit 6fdcba641e
1 changed files with 2 additions and 3 deletions

View File

@ -49,8 +49,7 @@ push_on_exit_callback(Server, Callback) when is_function(Callback, 0) ->
init(Parent) ->
process_flag(trap_exit, true),
Ref = monitor(process, Parent),
{ok, #{callbacks => [], owner => {Ref, Parent}}}.
{ok, #{callbacks => [], owner => Parent}}.
terminate(_Reason, #{callbacks := Callbacks}) ->
lists:foreach(fun(Fun) -> Fun() end, Callbacks).
@ -63,7 +62,7 @@ handle_call(_Req, _From, State) ->
handle_cast(_Req, State) ->
{noreply, State}.
handle_info({'DOWN', Ref, process, Parent, _Reason}, State = #{owner := {Ref, Parent}}) ->
handle_info({'EXIT', Parent, _Reason}, State = #{owner := Parent}) ->
{stop, normal, State};
handle_info(_Msg, State) ->
{noreply, State}.