[erlang-questions] max timeout
Serge Aleynikov
saleyn@REDACTED
Wed Aug 20 12:33:51 CEST 2008
Alpár Jüttner wrote:
> Hi,
>
> As I recall, someone noted on that thread that timer:sleep() works well
> for arbitrarily large numbers.
>
> Now I looked at the source and found that this is _not_ true. Strangely
> enough, all the functions of the timer modules seem to work correctly
> with large numbers _except_ timer:sleep() which has a definition as
> simple as this:
>
> sleep(T) ->
> receive
> after T -> ok
> end.
This is the reason why in this thread I was questioning the max timeout
of the receive statement as opposed to timer:sleep/1 implemented in
bytecode. ;-)
> It might be worth fixing.
>
>> 1. 2^32 (this is what's documented, but only seems to work in the shell)
>> 2. 2^32-1 = 49.5 days
>> 3. Erlang's small integers (2^27-1 = 1.5 days)
>
> 4. timer.erl says this:
> -define(MAX_TIMEOUT, 16#0800000).
Though, if you look at the use of this define in timer.erl, it's there
merely to prevent the cleanup loop of already timed-out timers from
dealing with bignums, so it doesn't quite tell us about the intended
design of the receive statement.
Regards,
Serge
More information about the erlang-questions
mailing list