Reputation: 3070
In Erlang if two processes A and B are sending message to a process C simultaneously. Will there be a race condition?
Will C receive the complete message from A and then proceed for the message from B? or is it that C is likely be going to receive chunks of A's message along with chunks of B's message?
Upvotes: 4
Views: 415
Reputation: 26121
Message receiving is an atomic operation.
If you are interested how it is done, read the source code of VM. If I simplify it, the sending process is doing those steps:
As you can see, copying is done outside (before) critical section and the critical section is pretty fast. It is just juggling with few pointers.
Upvotes: 5