Real Time-ing

Chris Wright via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Dec 8 09:16:53 PST 2015


On Tue, 08 Dec 2015 15:35:18 +0000, Taylor Hillegeist wrote:

> So, I mostly do programming that is of run to completion verity.
> But I have a dream of calling functions periodically. So my question is:
> 
> What is the best (most time accurate) way to call a function every n
> time units?

Busy-wait and access the CPU's high precision clock.

If you have an extended wait and don't want to busy-wait the whole time, 
sleep up to, say, 5ms before the time you want to call the function, then 
busy-wait.


More information about the Digitalmars-d-learn mailing list