-
ID
-
stack
-
msg queue (incoming)
-
Two actors have no shared memory
One of the actors has a counter. I want other actors to be able to increment the counter and be able to get the value of the counter
We’ll make two messages: { QUERY : my_pid; } { INCREMENT }
send self(), {:TEST} # send message
# how to receieve messages
# receive blocks until it receives the message
receive do
{:TEST} -> IO.puts("Got it!")
# after receiving, the message is deleted from the message
# queue
end# Name the current process so others can communicate with it
Process.register self(), :bestprocess
receive do {:TEST, x} -> IO.puts(x) end# send a message to the "bestprocess" process on the node
# "foo@tenger"
send {:bestprocess, :"foo@tenger"}, {:TEST, "barf"}