Merge pull request #81 from vibe-d/windows_event_poll_fixes

Remove special case for zero-wait processing off events.
This commit is contained in:
Sönke Ludwig 2018-06-05 12:12:31 +02:00 committed by GitHub
commit 00ef149c04
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -73,12 +73,6 @@ final class WinAPIEventDriverCore : EventDriverCore {
if (!waiterCount) return ExitReason.outOfWaiters; if (!waiterCount) return ExitReason.outOfWaiters;
bool got_event; bool got_event;
if (timeout <= 0.seconds) {
got_event = doProcessEvents(0.seconds);
got_event |= m_timers.process(currStdTime);
return got_event ? ExitReason.idle : ExitReason.timeout;
} else {
long now = currStdTime; long now = currStdTime;
do { do {
auto nextto = min(m_timers.getNextTimeout(now), timeout); auto nextto = min(m_timers.getNextTimeout(now), timeout);
@ -94,7 +88,6 @@ final class WinAPIEventDriverCore : EventDriverCore {
if (timeout != Duration.max) if (timeout != Duration.max)
timeout -= (now - prev_step).hnsecs; timeout -= (now - prev_step).hnsecs;
} while (timeout > 0.seconds); } while (timeout > 0.seconds);
}
if (!waiterCount) return ExitReason.outOfWaiters; if (!waiterCount) return ExitReason.outOfWaiters;
if (got_event) return ExitReason.idle; if (got_event) return ExitReason.idle;
@ -159,14 +152,13 @@ final class WinAPIEventDriverCore : EventDriverCore {
private bool doProcessEvents(Duration max_wait) private bool doProcessEvents(Duration max_wait)
{ {
import core.time : seconds; import core.time : seconds;
import std.algorithm.comparison : min; import std.algorithm.comparison : min, max;
executeThreadCallbacks(); executeThreadCallbacks();
bool got_event; bool got_event;
if (max_wait > 0.seconds) { DWORD timeout_msecs = max_wait == Duration.max ? INFINITE : cast(DWORD)min(max(max_wait.total!"msecs", 0), DWORD.max);
DWORD timeout_msecs = max_wait == Duration.max ? INFINITE : cast(DWORD)min(max_wait.total!"msecs", DWORD.max);
auto ret = () @trusted { return MsgWaitForMultipleObjectsEx(cast(DWORD)m_registeredEvents.length, m_registeredEvents.ptr, auto ret = () @trusted { return MsgWaitForMultipleObjectsEx(cast(DWORD)m_registeredEvents.length, m_registeredEvents.ptr,
timeout_msecs, QS_ALLEVENTS, MWMO_ALERTABLE|MWMO_INPUTAVAILABLE); } (); timeout_msecs, QS_ALLEVENTS, MWMO_ALERTABLE|MWMO_INPUTAVAILABLE); } ();
@ -192,7 +184,6 @@ final class WinAPIEventDriverCore : EventDriverCore {
foreach( fw; to_remove ) foreach( fw; to_remove )
m_fileWriters.remove(fw); m_fileWriters.remove(fw);
}*/ }*/
}
MSG msg; MSG msg;
//uint cnt = 0; //uint cnt = 0;