Fix waiter count bookkeeping in PosixEventDriverEvents.

This commit is contained in:
Sönke Ludwig 2017-01-23 11:34:14 +01:00
parent e5078ad399
commit d6321a2b52
No known key found for this signature in database
GPG key ID: D95E8DB493EE314C

View file

@ -1231,11 +1231,14 @@ final class PosixEventDriverEvents(Loop : PosixEventLoop, Sockets : EventDriverS
//log("emitting only for this thread (%s waiters)", m_fds[event].waiters.length); //log("emitting only for this thread (%s waiters)", m_fds[event].waiters.length);
foreach (w; slot.waiters.consume) { foreach (w; slot.waiters.consume) {
//log("emitting waiter %s %s", cast(void*)w.funcptr, w.ptr); //log("emitting waiter %s %s", cast(void*)w.funcptr, w.ptr);
m_loop.m_waiterCount--;
w(event); w(event);
} }
} else { } else {
if (!slot.waiters.empty) if (!slot.waiters.empty) {
m_loop.m_waiterCount--;
slot.waiters.consumeOne()(event); slot.waiters.consumeOne()(event);
}
} }
} }
@ -1254,7 +1257,7 @@ final class PosixEventDriverEvents(Loop : PosixEventLoop, Sockets : EventDriverS
final override void wait(EventID event, EventCallback on_event) final override void wait(EventID event, EventCallback on_event)
{ {
m_loop.m_waiterCount++; m_loop.m_waiterCount++;
return getSlot(event).waiters.put(on_event); getSlot(event).waiters.put(on_event);
} }
final override void cancelWait(EventID event, EventCallback on_event) final override void cancelWait(EventID event, EventCallback on_event)