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,13 +1231,16 @@ final class PosixEventDriverEvents(Loop : PosixEventLoop, Sockets : EventDriverS
//log("emitting only for this thread (%s waiters)", m_fds[event].waiters.length);
foreach (w; slot.waiters.consume) {
//log("emitting waiter %s %s", cast(void*)w.funcptr, w.ptr);
m_loop.m_waiterCount--;
w(event);
}
} else {
if (!slot.waiters.empty)
if (!slot.waiters.empty) {
m_loop.m_waiterCount--;
slot.waiters.consumeOne()(event);
}
}
}
final override void trigger(EventID event, bool notify_all)
shared @trusted {
@ -1254,7 +1257,7 @@ final class PosixEventDriverEvents(Loop : PosixEventLoop, Sockets : EventDriverS
final override void wait(EventID event, EventCallback on_event)
{
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)