High-resolution thread sleep
Ivan Trombley
itrombley at dot-borg.org
Fri Dec 15 01:11:00 UTC 2017
On Friday, 15 December 2017 at 00:39:13 UTC, Rene Zwanenburg
wrote:
> 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 ;)
You know, you're right. I'm over-thinking this. Keep it simple.
:)
More information about the Digitalmars-d-learn
mailing list