[erlang-questions] Newbie question: wait until an absolute time

Christian S chsu79@REDACTED
Fri Feb 1 14:52:08 CET 2008


On Feb 1, 2008 2:26 PM, Kostis Sagonas <kostis@REDACTED> wrote:
> Alpár Jüttner wrote:
> > Anyway, is there any easy way to use a larger timeout than it is
> > representable by a single integer?
>
> Yes. As timeout value you can also use the atom 'infinity' ;-)
>
> Seriously now, your question does not make much sense.  Erlang has
> integers that can grow quite a bit: as much as the memory of your
> machine allows them to. In Erlang, integer values are not restricted to
> those that fit in 32 or 64 bits. So, you can pretty much use any integer
> you like.

I recall reading somewhere that the Timeout in

receive
   ...
after Timeout ->
  ...
end.

Has a 32/64bit maximum because of C-runtime-reasons. Maybe this was so
once, or maybe my memory is faulty.

If I knew that I would have to do something, such as turning on the
VCR  at 2009-12-24 19:00 for Karl Bertil Jonsons julafton on TV, I
doubt I would just want to do "Timeout = VCRMillis - NowMillis,
sleep(Timeout)" anyway. Instead I would limit my sleep to perhaps
day-intervals, and close down to smaller intervals when I get closer
to the absolute time. Such code would perhaps warrant a special
function that does all that for me.



More information about the erlang-questions mailing list