[erlang-questions] Why use send_after to send a message is reverse?

Jesper Louis Andersen jesper.louis.andersen@REDACTED
Tue Jun 9 15:25:57 CEST 2015


On Tue, Jun 9, 2015 at 1:32 PM, Dao Gui <guidao1013@REDACTED> wrote:

> this output is:
> dddd:2
> dddd:1
>

Not always!

Suppose we have:

                erlang:send_after(1000,Pid, 1),
                timer:sleep(1), %% Simulate that we get broken here and
other work has to be carried out
                erlang:send_after(1000,Pid,2).

Then the answer is

dddd:1
dddd:2

In other words, you better not rely on messages sent in the same time slot
have the same ordering every time around. In R18, with multiple timer
wheels, the situation is even more nondeterministic.

-- 
J.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150609/127804ea/attachment.htm>


More information about the erlang-questions mailing list