rework events
- ManualTrigger/TimeTrigger should be reworked as EventLoop. Every EventLoop is coupled with a ResourceOwner.
- An EventLoop can have multiple
FileDescriptor
s associated, but only one timer. - By default the EventLoop will continue working until explicitly stopped (this is different from previous EventPool events, which had to be re-enabled).
The interface:
class Something : public ResourceOwner {
EventLoop loop;
void setup() {
loop.setup(Ref(this), {fileDescriptor, anotherFileDescriptor}); // using a Deque list of pointers
}
void event(EventLoop::Control& ev) {
if (fileDescriptor(ev).read().triggered()) {
}
control.timeOutIn(500_ms) or control.timeOutAt(absoluteTime);
control.stop();
}
void someOtherFuncRunningOnResourceOwner() {
control.ensure(this); // starts if stop() is called before on control
}
};
Additional interfaces:
FileDescriptor::reset(int fd)
-
EventLoop::add(FileDescriptor&)
(and remove)
Edited by Bernard van Gastel