Support pumping non-delayed events in async::event_loop
This commit is contained in:
parent
abd40bfa4d
commit
148dc60d40
2 changed files with 13 additions and 0 deletions
|
|
@ -28,6 +28,9 @@ namespace psemek::async
|
|||
|
||||
~event_loop() override { stop(); }
|
||||
|
||||
// wait all non-delayed events
|
||||
void pump();
|
||||
|
||||
private:
|
||||
util::synchronized_queue<task> queue_;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -49,4 +49,14 @@ namespace psemek::async
|
|||
return queue_.size();
|
||||
}
|
||||
|
||||
void event_loop::pump()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
auto t = queue_.try_pop();
|
||||
if (!t) break;
|
||||
(*t)();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue