diff options
author | Florent Le Coz <louiz@louiz.org> | 2013-11-17 12:55:45 +0100 |
---|---|---|
committer | Florent Le Coz <louiz@louiz.org> | 2013-11-21 00:35:15 +0100 |
commit | b569240a55a0df3a78d3cb3e1e673e9347e531c0 (patch) | |
tree | 99d548ea95c3180f273d9ee3e94f44041757772f /src/network/poller.hpp | |
parent | 1e122d3342ef4336f17bd5606be7101748627415 (diff) | |
download | biboumi-b569240a55a0df3a78d3cb3e1e673e9347e531c0.tar.gz biboumi-b569240a55a0df3a78d3cb3e1e673e9347e531c0.tar.bz2 biboumi-b569240a55a0df3a78d3cb3e1e673e9347e531c0.tar.xz biboumi-b569240a55a0df3a78d3cb3e1e673e9347e531c0.zip |
Use epoll
Diffstat (limited to 'src/network/poller.hpp')
-rw-r--r-- | src/network/poller.hpp | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/network/poller.hpp b/src/network/poller.hpp index 319236b..e6ce7f2 100644 --- a/src/network/poller.hpp +++ b/src/network/poller.hpp @@ -10,26 +10,28 @@ #define EPOLL 2 #define KQUEUE 3 -#define POLLER POLL +#include <config.h> +#ifndef POLLER + // Default standard poller + #define POLLER EPOLL +#endif #if POLLER == POLL #include <poll.h> - // TODO, dynamic size, without artificial limit #define MAX_POLL_FD_NUMBER 4096 +#elif POLLER == EPOLL + #include <sys/epoll.h> #endif /** - * We pass some SocketHandlers to this the Poller, which uses + * We pass some SocketHandlers to this Poller, which uses * poll/epoll/kqueue/select etc to wait for events on these SocketHandlers, * and call the callbacks when event occurs. * - * TODO: support for all these pollers: - * - poll(2) (mandatory) - * - epoll(7) + * TODO: support these pollers: * - kqueue(2) */ - class Poller { public: @@ -48,12 +50,12 @@ public: * Signal the poller that he needs to watch for send events for the given * SocketHandler. */ - void watch_send_events(const SocketHandler* const socket_handler); + void watch_send_events(SocketHandler* socket_handler); /** * Signal the poller that he needs to stop watching for send events for * this SocketHandler. */ - void stop_watching_send_events(const SocketHandler* const socket_handler); + void stop_watching_send_events(SocketHandler* socket_handler); /** * Wait for all watched events, and call the SocketHandlers' callbacks * when one is ready. @@ -72,6 +74,8 @@ private: #if POLLER == POLL struct pollfd fds[MAX_POLL_FD_NUMBER]; nfds_t nfds; +#elif POLLER == EPOLL + int epfd; #endif Poller(const Poller&) = delete; |