[erlang-questions] gen_server and init
Sergej Jurečko
sergej.jurecko@REDACTED
Mon Jul 27 16:34:58 CEST 2015
If something is in the message queue before init is done executing, that timeout will never get called. Timeout means execute only if nothing else happens during. You should be using self() ! timeout
Sergej
From: <erlang-questions-bounces@REDACTED> on behalf of Matthew Evans
Date: Monday 27 July 2015 16:25
To: "erlang-questions@REDACTED"
Subject: [erlang-questions] gen_server and init
Hi,
We have used this pattern in gen_servers for a long time now:
init(_) ->
%% Some stuff
{ok, #state{}, 0}.
%%%
%%%
handle_info(timeout, State) ->
%% Init stuff
{noreply,State}
Basically the idea is to prevent init from blocking and to have init/1 return with a timeout of 0 causing an immediate timeout message to be invoked in the handle_info.
Here's what's odd. Sometimes this timeout does not fire. It doesn't appear that any message is getting sent, but I would imagine that since it's a registered gen_server there is no way that can happen.
Does anyone have any ideas?
We are running vsn 17.1, and ntp is enabled on the host (Linux).
Thanks
_______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://erlang.org/mailman/listinfo/erlang-questions
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150727/25cccd69/attachment.htm>
More information about the erlang-questions
mailing list