When performing a receive , the BEAM VM scans the mailbox in order to find the first suitable (matching) message, and blocks the process if it does not find any. The 'trick' is that, since it's impossible for a new reference to be in the mailbox before it was created, there's no need to scan the whole mailbox when receive {Reference, Term} , only from the point where Reference was created. That's the meaning of the following phrase: The compiler recognizes code that uses a newly created reference (ref) in a receive (see [ref_trick_code]), and emits code to avoid the long inbox scan since the new ref can not already be in the inbox.
1条答案
按热度按时间ny6fqffe1#
When performing a
receive
, the BEAM VM scans the mailbox in order to find the first suitable (matching) message, and blocks the process if it does not find any.The 'trick' is that, since it's impossible for a new reference to be in the mailbox before it was created, there's no need to scan the whole mailbox when
receive {Reference, Term}
, only from the point whereReference
was created.That's the meaning of the following phrase:
The compiler recognizes code that uses a newly created reference (ref) in a receive (see [ref_trick_code]), and emits code to avoid the long inbox scan since the new ref can not already be in the inbox.