Skip to content
This repository has been archived by the owner on Oct 5, 2023. It is now read-only.

Commit

Permalink
add pid/port monitoring
Browse files Browse the repository at this point in the history
  • Loading branch information
pouriya committed Jun 12, 2017
1 parent 742e6df commit 1a0a412
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/lb.erl
Original file line number Diff line number Diff line change
Expand Up @@ -885,8 +885,10 @@ reply(Name, Dbg, {Pid, Tag}=From, Msg) ->


do_subscribe(#?STATE{objects = []}=State, Object) ->
do_monitor(Object),
{State#?STATE{objects = [Object], object = Object}, ok};
do_subscribe(#?STATE{objects = Objects}=State, Object) ->
do_monitor(Object),
{State#?STATE{objects = [Object|Objects]}, ok}.


Expand All @@ -895,6 +897,17 @@ do_subscribe(#?STATE{objects = Objects}=State, Object) ->



do_monitor(Object) when erlang:is_pid(Object) ->
erlang:monitor(process, Object);
do_monitor(Object) when erlang:is_port(Object) ->
erlang:monitor(port, Object).







do_unsubscribe(#?STATE{objects = [Object]}=State, Object) ->
{State#?STATE{objects = [], object = undefined}, ok};
do_unsubscribe(#?STATE{objects = Objects, object =Object}=State, Object) ->
Expand Down

0 comments on commit 1a0a412

Please sign in to comment.