baotiao
baotiao

Reputation: 795

Erlang process sending message

I understand that Erlang process message is sync. When I do

Pid ! message

  1. the sending message thread return right now
  2. the sending message thread will confirm the message has put in the Pid's message queue and then return.

Which choice will the sending message thread do ?

Upvotes: 2

Views: 973

Answers (3)

I GIVE CRAP ANSWERS
I GIVE CRAP ANSWERS

Reputation: 18849

In Erlang, message passing is asynchronous. The sender never blocks. Message delivery is not guaranteed. Caveats:

  • If messaging a local process, then in practice, messages always arrive and do so very quickly.
  • If messaging a remote process, then messages will be queued for sending. But due to the nature of TCP and distribution, it is not guaranteed that the message will be transferred and processed by the other party.

Upvotes: 2

Carlo
Carlo

Reputation: 1714

I believe your understanding might be wrong. Erlang message passing is asynchronous. For example have a look here. To answer your question then the option number 1 is what's happening here.

Upvotes: 3

BlackMamba
BlackMamba

Reputation: 10254

I think

the sending message thread return right now.

is right.

because Pid ! message just put the message into the message queue of process Pid. the process Pid will use receive to check its message queue. this is nothing with the sending process.

Upvotes: 0

Related Questions