|
![](/i/fill.gif) |
Invisible wrote:
> Even so, I'd suggest that it's more or less infeasible to determine how
> long a calculation takes.
Nonsense. People do it all the time. If nothing else, do it by
experimentation. Try sleeping one milisecond using the technique, measure
how fast the clock goes, and adjust. You can even adjust dynamically based
on when you wake up. If you wake up 29 microseconds later than you asked,
subtract 29 microseconds the next time.
> Either way, this would be *so much* easier if I could ask for absolute
> rather than relative start times...
Read the absolute time, subtract it from the time you want to wake up,
subtract the length of time you were late last time, and sleep that long.
When you wake up, read the absolute time, subtract it from the time you
wanted to wake up, and store that for the next cycle.
> (I also love the way the internal implementation look like it's likely
> to fail if you call threadDelay just before midnight... That's a nice
> touch.)
What system are you looking at?
--
Darren New, San Diego CA, USA (PST)
Eiffel - The language that lets you specify exactly
that the code does what you think it does, even if
it doesn't do what you wanted.
Post a reply to this message
|
![](/i/fill.gif) |