[erlang-questions] Re: timer server timeout

johan munk johanmunk@REDACTED
Mon Apr 26 10:17:54 CEST 2010


On Mon, Apr 26, 2010 at 9:57 AM, Ulf Wiger
<ulf.wiger@REDACTED>wrote:

>
>
> I never use the internal timeout in gen_server for anything
> much, for this very reason. It can be useful as an inactivity
> timeout, but if you really want to get a reliable timeout since
> a specific point in time, you have to set a timer. Fortunately,
> the timer BIFs are very cheap (don't use the functions in the
> timer module; use erlang:send_after/3 or erlang:start_timer/3.)
>

ah OK - thanks. Only my one-shot timers needs to be more reliable than what
the timer module provide.

I suggest that the doc of the timer module is extended with info about this
gotcha. It says:

"The timeouts are not exact, but should be at least as long as requested."

which holds but one gets the impression that  timeouts are guaranteed (in
finite time).




> BR,
> Ulf W
>
>
>
>  On Wed, Apr 21, 2010 at 10:05 PM, johan munk <johanmunk@REDACTED> wrote:
>>
>>  Following the control flow in the gen_server, sys, and timer modules I
>>> see
>>> this:
>>> Calling sys:get_status(timer_server) will "reset" the "after time" in the
>>> loop function of gen_server. As the timer server uses that time to get a
>>> timeout if no other messages are received, one can potentially cause
>>> timers
>>> to never trigger.
>>> Is this a known issue/feature?
>>>
>>> /JM
>>>
>>>
>>
>
> --
> Ulf Wiger
> CTO, Erlang Solutions Ltd, formerly Erlang Training & Consulting Ltd
> http://www.erlang-solutions.com
> ---------------------------------------------------
>
> ---------------------------------------------------
>
> WE'VE CHANGED NAMES!
>
> Since January 1st 2010 Erlang Training and Consulting Ltd. has become
> ERLANG SOLUTIONS LTD.
>
> www.erlang-solutions.com
>
>


More information about the erlang-questions mailing list