diff options
author | Florent Le Coz <louiz@louiz.org> | 2013-12-21 21:04:41 +0100 |
---|---|---|
committer | Florent Le Coz <louiz@louiz.org> | 2014-01-04 01:59:14 +0100 |
commit | 3afb63a650b8b925ce1ba722dd42b7418f623713 (patch) | |
tree | 594cdfdd2a0abf302229ec000c2177ec001bfeaf /src/network/poller.hpp | |
parent | df59a09163bd988ad4da533c4f39de057a3701ba (diff) | |
download | biboumi-3afb63a650b8b925ce1ba722dd42b7418f623713.tar.gz biboumi-3afb63a650b8b925ce1ba722dd42b7418f623713.tar.bz2 biboumi-3afb63a650b8b925ce1ba722dd42b7418f623713.tar.xz biboumi-3afb63a650b8b925ce1ba722dd42b7418f623713.zip |
Shutdown cleanly on SIGINT
Diffstat (limited to 'src/network/poller.hpp')
-rw-r--r-- | src/network/poller.hpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/network/poller.hpp b/src/network/poller.hpp index fe52fda..dc087a2 100644 --- a/src/network/poller.hpp +++ b/src/network/poller.hpp @@ -5,6 +5,7 @@ #include <unordered_map> #include <memory> +#include <chrono> #define POLL 1 #define EPOLL 2 @@ -58,10 +59,17 @@ public: void stop_watching_send_events(SocketHandler* socket_handler); /** * Wait for all watched events, and call the SocketHandlers' callbacks - * when one is ready. - * Returns false if there are 0 SocketHandler in the list. + * when one is ready. Returns if nothing happened before the provided + * timeout. If the timeout is 0, it waits forever. If there is no + * watched event, returns -1 immediately, ignoring the timeout value. + * Otherwise, returns the number of event handled. If 0 is returned this + * means that we were interrupted by a signal, or the timeout occured. */ - bool poll(); + int poll(const std::chrono::milliseconds& timeout); + /** + * Returns the number of SocketHandlers managed by the poller. + */ + size_t size() const; private: /** |