[erlang-questions] max timeout

Bjorn Gustavsson bgustavsson@REDACTED
Mon Aug 25 09:18:18 CEST 2008


On Sun, Aug 24, 2008 at 9:25 PM, Per Hedeland <per@REDACTED> wrote:

> "Hynek Vychodil" <vychodil.hynek@REDACTED> wrote:
> >
> >          {ok, _} = send_after(Time, Ref),
>
> >> It should be much more simpler to do it without modify timer_server:
> >>
> >> sleep(Time) ->
> >>     case whereis(timer_server) of
> >>        undefined -> receive after Time -> ok end;
> >>        _ ->
> >>           Ref = make_ref(),
> >>           send_after(Time, Ref),
> >>           receive Ref -> ok end
> >>     end.
>
> Matter of taste perhaps, whether you prefer the absolute minimum of
> change vs regularity of implementation. One thing that often falls out
> of the latter is consistency in API, such that you don't end up with one
> API function doing a badmatch crash on erroneous input, while all the
> others return {error, badarg}. And of course one could ask why create an
> unneeded ref, or why require two messages from the server when you only
> need one, but that's more in the nitpicking area.
>

We have had problems with the timer server becoming seriously overloaded.
See:

http://erlang.org/doc/efficiency_guide/commoncaveats.html#3.2

Therefore, I think that the proper way is to do "receive after" in a
try/catch,
and only call the timer server if the timeout value is invalid.

If anyone submits a patch like that, we'll try to include it in R12B-4.

/Bjorn



>
> --Per Hedeland
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>



-- 
Björn Gustavsson, Erlang/OTP, Ericsson AB
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20080825/0704ff7b/attachment.htm>


More information about the erlang-questions mailing list