Message Passing
The communication model (among processes) in Erlang is message passing. No much need to be said about this. Erlang processes share no memory. The way that processes communicate is via (asynchronous) message passing. Every process (even the shell) holds a mailbox queue where incoming messages are placed until received by the process. Message passing is asynchronous because the sending process does not block on send. On the other hand, receiving a message in Erlang is a blocking operation.
Characteristics
In this subsection I will describe some of the characteristics of message passing in Erlang.
Asynchronous
As I already mentioned, message passing in Erlang is a non-blocking operation.
Data Copy
The message’s data are copied from the sending process to the receiver’s message queue, so the receiver gets a fresh copy of the data.
Ordering
Erlang runtime guarantees that if two messages are sent from node A
to node B
and both are delivered, then the ordering of these messages is kept (causal ordering).
Successful Send
The send operation always succeeds (even if the target is a non-existing process) and evaluates to the data sent. An exception is when trying to send data to a non-existing registered process.
Read the rest of this entry »