[erlang-questions] writing a delay loop without now()
Wed Feb 18 08:19:34 CET 2009
Would you consider calling erlang:yield() between two subsequent calls to
NOTE: I've tried it from shell and it didn't make any difference, possibly
because the shell is the only process that is actually doing something,
hence nobody to yield the CPU usage to. Also not sure how this would behave
under the heavy system load, however, according to the manual, the
erlang:yield() is faster than receive after 1 -> ok end.
If you indeed try this approach, could you please give me some feedback on
[mailto:] On Behalf Of James Hague
Sent: 18 February 2009 03:11 AM
To: Erlang Questions
Subject: [erlang-questions] writing a delay loop without now()
I need more resolution than timer:sleep() will give me. (timer:sleep
gives widely varying results, based on the underlying operating
system). Ugly though it may be, I've been using a spin loop based on
now() and timer:now_diff(). While this appears to work, based on the
values returned by now(), it runs much faster than wall clock time.
I'm assuming it's because of this:
"It is also guaranteed that subsequent calls to this BIF returns
continuously increasing values."
Is there another BIF I should be using? I'm hoping I don't have to
write my own linked-in driver for this.
erlang-questions mailing list
More information about the erlang-questions