[erlang-questions] embedded timeouts
Mon Jul 5 15:33:48 CEST 2010
The problem is that the "after Timeout" closure is never called. The loop never stops !
> Hi all,
> Why the first timeout never happens ?
Does the function in init/1 receive a message?
If it does, and loop/1 is called, it is no longer inside
the receive clause, and the 'after' clause will not
execute (it simply means, do this if no message has arrived
within Timeout milliseconds).
If no message is sent to the receive clause in init/1,
loop() will never be called.
> How must be structured this code in order to have two timeouts ?
> init(Timeout)- >
> after Timeout - >
> loop()- >
> receive after 1000 - > 0 end
CTO, Erlang Solutions Ltd, formerly Erlang Training & Consulting Ltd
More information about the erlang-questions