High-resolution thread sleep

Rene Zwanenburg renezwanenburg at gmail.com
Fri Dec 15 00:39:13 UTC 2017


On Thursday, 14 December 2017 at 23:45:18 UTC, Ivan Trombley 
wrote:
> Something along the lines of this:
>
> while (render)
> {
>   immutable auto startTime = MonoTime.currTime;
>
>   // Render the frame...
>
>   immutable auto remain = m_frameDuration - (startTime - 
> MonoTime.currTime);
>   if (remain > Duration.zero)
>     Thread.sleep(remain);
> }

In that case, the best thing you can do is use vsync as the 
waiting mechanism ;)


More information about the Digitalmars-d-learn mailing list