Guest User

Untitled

a guest
Jun 29th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Erlang 0.49 KB | None | 0 0
  1. handle_request(RPID,Tuple,Pattern,Mode)
  2.     recieve                                     % main listener loop
  3.         {RPID, _, Pattern,"take"} ->            % someone wants tuple matching pattern
  4.             recieve                             % Single loop through stored messages:
  5.                 {_, Tuple, _ , "put"} ->        % look for tuples sent with "put"
  6.                     case match (Tuple, Pattern) of
  7.                     true ->
  8.                         RPID ! Tuple;           % yay, simple return.
  9.                     false ->
  10.                         % Well, RPID should block here.. dunno how.
  11.             after
  12.                 0 ->
  13.             end; % end "take" recieve pattern
  14.     end.
Add Comment
Please, Sign In to add comment