test(refactor): no need for monitor
the janitor is already linked to the parent
This commit is contained in:
parent
a0e11f75d9
commit
6fdcba641e
|
@ -49,8 +49,7 @@ push_on_exit_callback(Server, Callback) when is_function(Callback, 0) ->
|
||||||
|
|
||||||
init(Parent) ->
|
init(Parent) ->
|
||||||
process_flag(trap_exit, true),
|
process_flag(trap_exit, true),
|
||||||
Ref = monitor(process, Parent),
|
{ok, #{callbacks => [], owner => Parent}}.
|
||||||
{ok, #{callbacks => [], owner => {Ref, Parent}}}.
|
|
||||||
|
|
||||||
terminate(_Reason, #{callbacks := Callbacks}) ->
|
terminate(_Reason, #{callbacks := Callbacks}) ->
|
||||||
lists:foreach(fun(Fun) -> Fun() end, Callbacks).
|
lists:foreach(fun(Fun) -> Fun() end, Callbacks).
|
||||||
|
@ -63,7 +62,7 @@ handle_call(_Req, _From, State) ->
|
||||||
handle_cast(_Req, State) ->
|
handle_cast(_Req, State) ->
|
||||||
{noreply, 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};
|
{stop, normal, State};
|
||||||
handle_info(_Msg, State) ->
|
handle_info(_Msg, State) ->
|
||||||
{noreply, State}.
|
{noreply, State}.
|
||||||
|
|
Loading…
Reference in New Issue