17 #ifndef ZMQPP_POLLER_HPP_ 
   18 #define ZMQPP_POLLER_HPP_ 
   20 #include <unordered_map> 
   46 #if ((ZMQ_VERSION_MAJOR == 4 && ZMQ_VERSION_MINOR >= 2) || ZMQ_VERSION_MAJOR > 4) 
   68     void add(socket_t& 
socket, 
short const event = poll_in);
 
   76     void add(
raw_socket_t const descriptor, 
short const event = poll_in | poll_error);
 
   85     void add(zmq_pollitem_t 
const& item);
 
  111     bool has(zmq_pollitem_t 
const& item);
 
  118     void remove(socket_t 
const& 
socket);
 
  132     void remove(zmq_pollitem_t 
const& item);
 
  156     void check_for(zmq_pollitem_t 
const& item, 
short const event);
 
  169     bool poll(
long timeout = wait_forever);
 
  193     short events(zmq_pollitem_t 
const& item) 
const;
 
  203     template<
typename Watched>
 
  204     bool has_input(Watched 
const& watchable)
 const { 
return (
events(watchable) & poll_in) != 0; }
 
  214     template<
typename Watched>
 
  215     bool has_output(Watched 
const& watchable)
 const { 
return (
events(watchable) & poll_out) != 0; }
 
  228     template<
typename Watched>
 
  229     bool has_error(Watched 
const& watchable)
 const { 
return (
events(watchable) & poll_error) != 0; }
 
  233     std::unordered_map<void *, size_t> 
_index;
 
  236     void reindex(
size_t const index);
 
static const short poll_error
Definition: poller.hpp:44
 
bool has_output(Watched const &watchable) const 
Check either a standard socket or zmq socket for output events. 
Definition: poller.hpp:215
 
static const short poll_out
Definition: poller.hpp:43
 
poller()
Construct an empty polling model. 
Definition: poller.cpp:34
 
C++ wrapper around zmq. 
Definition: actor.cpp:29
 
void reindex(size_t const index)
Definition: poller.cpp:91
 
bool has(socket_t const &socket)
Check if we are monitoring a given socket with this poller. 
Definition: poller.cpp:74
 
The socket class represents the zmq sockets. 
Definition: socket.hpp:75
 
socket socket_t
socket type 
Definition: poller.hpp:28
 
int raw_socket_t
Definition: compatibility.hpp:116
 
void check_for(socket_t const &socket, short const event)
Update the monitored event flags for a given socket. 
Definition: poller.cpp:145
 
static const short poll_none
Definition: poller.hpp:41
 
short events(socket_t const &socket) const 
Get the event flags triggered for a socket. 
Definition: poller.cpp:201
 
bool poll(long timeout=wait_forever)
Poll for monitored events. 
Definition: poller.cpp:185
 
std::vector< zmq_pollitem_t > _items
Definition: poller.hpp:232
 
bool has_input(Watched const &watchable) const 
Check either a standard socket or zmq socket for input events. 
Definition: poller.hpp:204
 
static const long wait_forever
Definition: poller.hpp:39
 
static const short poll_pri
Definition: poller.hpp:47
 
void add(socket_t &socket, short const event=poll_in)
Add a socket to the polling model and set which events to monitor. 
Definition: poller.cpp:49
 
std::unordered_map< void *, size_t > _index
Definition: poller.hpp:233
 
static const short poll_in
Definition: poller.hpp:42
 
Polling wrapper. 
Definition: poller.hpp:36
 
~poller()
Cleanup poller. 
Definition: poller.cpp:42
 
std::unordered_map< raw_socket_t, size_t > _fdindex
Definition: poller.hpp:234
 
bool has_error(Watched const &watchable) const 
Check a standard socket (file descriptor or SOCKET). 
Definition: poller.hpp:229