ensure_started

Vladimir Sekissov svg@REDACTED
Sun Mar 23 21:29:51 CET 2003


Good day,

cpressey> >      after 0 -> % nobody wants to talk to me
cpressey> 
cpressey> Is there a guarantee that you won't get a message right here?

>From "Concurent Programming in Erlang" p.76:

	A timeout of 0 means that the timeout will occur immediately,
	but the system tries all messages currently in the mailbox first

If your mailbox is empty you haven't time to receive any other message
if you exit immediately.

I believe that mailbox scanning is atomic operation. There were some
explanations in this list how system changes management policy for
processes with huge mailboxes.

Best Regards,
Vladimir Sekissov

cpressey> > loop() ->
cpressey> >   receive
cpressey> >    Msg ->
cpressey> >     do_something,
cpressey> >     loop();
cpressey> >    please_die ->
cpressey> >      receive
cpressey> >        Msg -> % there are some messages, continue
cpressey> >          loop()
cpressey> >      after 0 -> % nobody wants to talk to me
cpressey> 
cpressey> Is there a guarantee that you won't get a message right here?
cpressey> 
cpressey> >        exit(shutdown)
cpressey> >      end
cpressey> >   end.
cpressey> > 
cpressey> > Best Regards,
cpressey> > Vladimir Sekissov
cpressey> 
cpressey> -Chris



More information about the erlang-questions mailing list