[erlang-questions] Do messages casted by Process A always get received before messages called by Process A?
Thu Oct 20 00:16:44 CEST 2011
B will receive the messages in the order they were sent (1,2,3 always) unless something highly creative is going on behind the scenes (i.e. someone is deliberately doing something crazy - if you can rule out crazy Erlangers, you get 1, 2, 3 always).
That sequence boils down to three message sends; the call for 1, the cast for 2 and the call for 3. Erlang guarantees that between pairs of processes (A, B), messages are delivered in the order they are sent. This coupled with the fact that gen_* processes messages received in order, means that you will get handle_call (1), handle_cast (2), handle_call(3) in B's gen_server callback module.
On 2011-10-19, at 15:09 , Kris Rasmussen wrote:
> Geoff, thanks for the response. I think I may have been ambiguous in my
> wording. To be more specific, can you tell me if the following is true:
> Imagine process A does the following:
> call(B, 1)
> cast(B, 2)
> call(B, 3)
> Will B always receive the messages in the order A sent them (1, 2, 3) as
> opposed to something like (1, 3, 2) occasionally?
> On Wed, Oct 19, 2011 at 3:00 PM, Geoff Cant <nem@REDACTED> wrote:
>> No, messages are handled in the order they arrive to a gen_* process. So if
>> you (1) call A, then (2) cast A, (1) will be handled before (2).
>> On 2011-10-19, at 14:46 , Kris Rasmussen wrote:
>>> Can I assume that casts will be processed before calls in erlang if sent
>>> from the same process? I would expect this to be the case given that I
>>> assume the only difference between a cast and a call is that a call waits
>>> for a response but I certainly could be wrong.
>>> erlang-questions mailing list
More information about the erlang-questions