From bb288f02848793a85b74262063d1bd9c7bc7dd78 Mon Sep 17 00:00:00 2001 From: Denis Krjuchkov Date: Thu, 28 Nov 2013 16:37:23 +0600 Subject: event: introduce generic API for internal event loop --- src/event/Loop.hxx | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) (limited to 'src/event/Loop.hxx') diff --git a/src/event/Loop.hxx b/src/event/Loop.hxx index f188c7cc0..029d01245 100644 --- a/src/event/Loop.hxx +++ b/src/event/Loop.hxx @@ -25,10 +25,7 @@ #include "Compiler.h" #ifdef USE_INTERNAL_EVENTLOOP -#ifdef USE_EPOLL -#include "system/EPollFD.hxx" -#endif - +#include "PollGroup.hxx" #include "thread/Mutex.hxx" #include "WakeFD.hxx" #include "SocketMonitor.hxx" @@ -99,13 +96,8 @@ class EventLoop final bool quit; -#ifdef USE_EPOLL - EPollFD epoll; - static constexpr unsigned MAX_EVENTS = 16; - unsigned n_events; - epoll_event events[MAX_EVENTS]; -#endif - + PollGroup poll_group; + PollResult poll_result; #endif #ifdef USE_GLIB_EVENTLOOP @@ -140,15 +132,11 @@ public: void Break(); bool AddFD(int _fd, unsigned flags, SocketMonitor &m) { -#ifdef USE_EPOLL - return epoll.Add(_fd, flags, &m); -#endif + return poll_group.Add(_fd, flags, &m); } bool ModifyFD(int _fd, unsigned flags, SocketMonitor &m) { -#ifdef USE_EPOLL - return epoll.Modify(_fd, flags, &m); -#endif + return poll_group.Modify(_fd, flags, &m); } /** @@ -156,7 +144,7 @@ public: * has been closed. This is like RemoveFD(), but does not * attempt to use #EPOLL_CTL_DEL. */ - void Abandon(SocketMonitor &m); + bool Abandon(int fd, SocketMonitor &m); bool RemoveFD(int fd, SocketMonitor &m); -- cgit v1.2.3