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

Matthias Lang matthias@REDACTED
Fri Feb 1 15:10:03 CET 2008


Christian S writes:

 > 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.

You seem to be right. This is pretty ugly:

   Eshell V5.5.4  (abort with ^G)
   1> receive after 16#ffffFFFF -> timeout end.
   timeout
   2> receive after 16#ffffFFF -> timeout end. 
   (hangs "forever", as it should)

I didn't systematically check whether this also happens for compiled
code too.

timer:sleep/1 seems to do the right thing.

 > Instead I would limit my sleep to perhaps day-intervals, and close
 > down to smaller intervals when I get closer to the absolute
 > time.

Realistically, that's a good idea, though day-intervals are rather
long if you ever want to load new code.

Matthias



More information about the erlang-questions mailing list