Support pumping non-delayed events in async::event_loop

This commit is contained in:
Nikita Lisitsa 2020-11-29 12:30:40 +03:00
parent abd40bfa4d
commit 148dc60d40
2 changed files with 13 additions and 0 deletions

View file

@ -28,6 +28,9 @@ namespace psemek::async
~event_loop() override { stop(); }
// wait all non-delayed events
void pump();
private:
util::synchronized_queue<task> queue_;
};

View file

@ -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)();
}
}
}