summaryrefslogtreecommitdiff
path: root/src/network/poller.hpp
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2013-11-21 00:37:01 +0100
committerFlorent Le Coz <louiz@louiz.org>2013-11-21 00:37:01 +0100
commit70a58a8f7152e775a1c6cdc15b3c9f23a7719f85 (patch)
treed37b7a377c3f76a2e51fe2dcebb2b19874773872 /src/network/poller.hpp
parente7a441e798e0a32fc4bb4021e058f3dc080adc80 (diff)
parentb72908548dc841de65dc9288a96c1abe648acc46 (diff)
downloadbiboumi-70a58a8f7152e775a1c6cdc15b3c9f23a7719f85.tar.gz
biboumi-70a58a8f7152e775a1c6cdc15b3c9f23a7719f85.tar.bz2
biboumi-70a58a8f7152e775a1c6cdc15b3c9f23a7719f85.tar.xz
biboumi-70a58a8f7152e775a1c6cdc15b3c9f23a7719f85.zip
Merge branch 'epolletc'
Diffstat (limited to 'src/network/poller.hpp')
-rw-r--r--src/network/poller.hpp24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/network/poller.hpp b/src/network/poller.hpp
index 319236b..fe52fda 100644
--- a/src/network/poller.hpp
+++ b/src/network/poller.hpp
@@ -9,27 +9,29 @@
#define POLL 1
#define EPOLL 2
#define KQUEUE 3
-
-#define POLLER POLL
+#include <config.h>
+#ifndef POLLER
+ #define POLLER POLL
+#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>
+#else
+ #error Invalid POLLER value
#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;