[erlang-questions] non-FIFO behavior in process mailboxes?
Ulf Wiger
ulf@REDACTED
Mon Apr 23 07:36:38 CEST 2012
On 23 Apr 2012, at 05:38, Michael Turner wrote:
> Before the client sends its ... BR? "Best Regards"? After a delay? Oh,
> *that's* what I forgot to do! ;-)
Uhm… yes, processes should be well-behaved. :)
> This bug came out of experimentation inspired by the recent discussion
> of initializing objects *after* their creation, a topic raised by
> Richard O'Keefe. And -- waddya know -- the problem here relates
> directly to his objection to this practice: inconsistent intermediate
> states. It appears that when you model your objects as processes, the
> danger is particularly acute.
For this reason, there is the gen_server:enter_loop(), which basically
(for one thing) allows you to stay in a protected state after init().
Also, plain_fsm:start_opt(Mod, InitF, …) allows you to have the InitF
return {reply, {ok, self()}, Cont}, where Cont is a continuation function
that let's the process proceed - possibly in a protected state.
BR,
Ulf
Ulf Wiger, Co-founder & Developer Advocate, Feuerlabs Inc.
http://feuerlabs.com
More information about the erlang-questions
mailing list