G2A Many GEOs
SHARE
TWEET

Linking 3 process - Rev 2

a guest Mar 9th, 2019 133 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -module(procslinked).
  2. -compile([export_all]).
  3.  
  4. starter() ->
  5.   spawn(?MODULE, the_first_p, [init]).
  6.  
  7. the_first_p(_) ->
  8.   register(pidfirstp, self()),
  9.   spawn_link(?MODULE, the_second_p, [init]),
  10.   the_first_p().
  11. the_first_p() ->
  12.   receive
  13.     {From, "to first p", Msg} ->
  14.       From ! {self(), "the_first_p()", Msg}
  15.   end,
  16.   the_first_p().
  17.  
  18. the_second_p(_) ->
  19.   register(pidsecondp, self()),
  20.   spawn_link(?MODULE, the_third_p, [init]),
  21.   the_second_p().
  22. the_second_p() ->
  23.   receive
  24.     {From, "to second p", Msg} ->
  25.       From ! {self(), "the_second_p()", Msg}
  26.   end,
  27.   the_second_p().
  28.  
  29. the_third_p(_) ->
  30.   register(pidthirdp, self()),
  31.   the_third_p().
  32. the_third_p() ->
  33.   receive
  34.     {From, "to third p", Msg} ->
  35.       From ! {self(), "the_third_p()", Msg}
  36.   end,
  37.   the_third_p().
  38.  
  39. call_the_first() ->
  40.   pidfirstp ! {self(), "to first p", "Halo first p!"},
  41.   receive
  42.     {Pid, FuncName, Msg} ->
  43.       {Pid, FuncName, Msg}
  44.   end.
  45.  
  46. call_the_second() ->
  47.   pidsecondp ! {self(), "to second p", "Halo second p!"},
  48.   receive
  49.     {Pid, FuncName, Msg} ->
  50.       {Pid, FuncName, Msg}
  51.   end.
  52.  
  53. call_the_third() ->
  54.   pidthirdp ! {self(), "to third p", "Halo third p!"},
  55.   receive
  56.     {Pid, FuncName, Msg} ->
  57.       {Pid, FuncName, Msg}
  58.   end.
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top