Add clearExitFlag().
This commit is contained in:
parent
1e27b33f26
commit
32394bb4c9
|
@ -48,6 +48,15 @@ interface EventDriver {
|
|||
*/
|
||||
void exit();
|
||||
|
||||
/** Resets the exit flag.
|
||||
|
||||
`processEvents` will automatically reset the exit flag before it returns
|
||||
with `ExitReason.exited`. However, if `exit` is called outside of
|
||||
`processEvents`, the next call to `processEvents` will return with
|
||||
`ExitCode.exited` immediately. This function can be used to avoid this.
|
||||
*/
|
||||
void clearExitFlag();
|
||||
|
||||
//
|
||||
// TCP
|
||||
//
|
||||
|
|
|
@ -106,6 +106,11 @@ abstract class PosixEventDriver : EventDriver {
|
|||
() @trusted { write(m_wakeupEvent, &one, one.sizeof); } ();
|
||||
}
|
||||
|
||||
final override void clearExitFlag()
|
||||
{
|
||||
m_exit = false;
|
||||
}
|
||||
|
||||
protected abstract bool doProcessEvents(Duration dur);
|
||||
abstract void dispose();
|
||||
|
||||
|
@ -491,8 +496,11 @@ abstract class PosixEventDriver : EventDriver {
|
|||
{
|
||||
assert(event < m_fds.length, "Invalid event ID passed to triggerEvent.");
|
||||
if (notify_all) {
|
||||
foreach (w; m_fds[event].waiters.consume)
|
||||
log("emitting");
|
||||
foreach (w; m_fds[event].waiters.consume) {
|
||||
log("emitting %s %s", cast(void*)w.funcptr, w.ptr);
|
||||
w(event);
|
||||
}
|
||||
} else {
|
||||
if (!m_fds[event].waiters.empty)
|
||||
m_fds[event].waiters.consumeOne();
|
||||
|
@ -505,6 +513,7 @@ abstract class PosixEventDriver : EventDriver {
|
|||
auto thisus = cast(PosixEventDriver)this;
|
||||
assert(event < thisus.m_fds.length, "Invalid event ID passed to shared triggerEvent.");
|
||||
int one = 1;
|
||||
log("emitting thread");
|
||||
if (notify_all) atomicStore(thisus.m_fds[event].triggerAll, true);
|
||||
() @trusted { write(event, &one, one.sizeof); } ();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue