[erlang-questions] Why use send_after to send a message is reverse?
Dao Gui
guidao1013@REDACTED
Tue Jun 9 13:32:50 CEST 2015
talk is cheap, show the code. ^_^
-module(t).
-export([main/0]).
main() ->
Pid = spawn(fun()->test2() end),
erlang:send_after(1000,Pid, 1),
erlang:send_after(1000,Pid,2).
test2() ->
receive
A ->
io:format("dddd:~p~n",[A]),
test2()
end.
--------------------------------------------------------------------------------------------------------
this output is:
dddd:2
dddd:1
then , I find this in time.c
* /* insert at head of list at slot */*
* p->next = tiw[tm];*
* p->prev = NULL;*
* if (p->next != NULL)*
* p->next->prev = p;*
* tiw[tm] = p;*
it insert head when we insert message
*/* Remove from list */*
*remove_timer(p);*
**timeout_tail = p; /* Insert in timeout queue */*
*timeout_tail = &p->next;*
it insert tail when it timeout.
----------------------------------------------------------------------------
Q: but why ? if message timeout, we can insert head. it can keep the order
of message. why don't do this?
other: my English is poor. if something wrong, i hope you forgive me.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150609/d92b3f93/attachment.htm>
More information about the erlang-questions
mailing list