added wait functionality

This commit is contained in:
keldu.magnus 2020-09-02 16:50:42 +02:00
parent d1157e854a
commit 8ae794332b
3 changed files with 35 additions and 3 deletions

View File

@ -183,6 +183,8 @@ public:
void poll() override { pollImpl(0); }
void wait() override { pollImpl(-1); }
void subscribe(IFdOwner &owner, int fd, uint32_t event_mask) {
if (epoll_fd < 0 || fd < 0) {
return;

View File

@ -181,14 +181,43 @@ bool EventLoop::turn() {
}
bool EventLoop::wait(const std::chrono::steady_clock::duration &duration) {
return false;
if (event_port) {
event_port->wait();
}
while (head) {
if (!turn()) {
return false;
}
}
return true;
}
bool EventLoop::wait(const std::chrono::steady_clock::time_point &time_point) {
return false;
if (event_port) {
event_port->wait();
}
while (head) {
if (!turn()) {
return false;
}
}
return true;
}
bool EventLoop::wait() { return false; }
bool EventLoop::wait() {
if (event_port) {
event_port->wait();
}
while (head) {
if (!turn()) {
return false;
}
}
return true;
}
bool EventLoop::poll() {
if (event_port) {

View File

@ -173,6 +173,7 @@ public:
virtual Conveyor<void> onSignal(Signal signal) = 0;
virtual void poll() = 0;
virtual void wait() = 0;
};
class SinkConveyorNode;