Commit 04653448 authored by jean-airoldie's avatar jean-airoldie

Problem: Cannot get thread safe socket fd

Solution: Add a method to get the zmq_poller's signaler fd. Then we can
associate a poller instance with every thread safe socket and use its
fd.
parent 501f9d8d
......@@ -709,6 +709,7 @@ ZMQ_EXPORT int zmq_poller_wait_all (void *poller,
zmq_poller_event_t *events,
int n_events,
long timeout);
ZMQ_EXPORT int zmq_poller_fd (void *poller);
#if defined _WIN32
ZMQ_EXPORT int
......
......@@ -86,6 +86,17 @@ bool zmq::socket_poller_t::check_tag ()
return _tag == 0xCAFEBABE;
}
int zmq::socket_poller_t::signaler_fd ()
{
if (_signaler) {
return _signaler->get_fd ();
} else {
// Only thread-safe socket types are guaranteed to have a signaler.
errno = EINVAL;
return -1;
}
}
int zmq::socket_poller_t::add (socket_base_t *socket_,
void *user_data_,
short events_)
......
......@@ -75,6 +75,8 @@ class socket_poller_t
int add_fd (fd_t fd_, void *user_data_, short events_);
int modify_fd (fd_t fd_, short events_);
int remove_fd (fd_t fd_);
// Returns the signaler's fd if there is one, otherwise errors.
int signaler_fd ();
int wait (event_t *event_, int n_events_, long timeout_);
......
......@@ -1278,6 +1278,11 @@ int zmq_poller_wait_all (void *poller_,
return rc;
}
int zmq_poller_fd (void *poller_)
{
return static_cast<zmq::socket_poller_t *> (poller_)->signaler_fd ();
}
// Peer-specific state
int zmq_socket_get_peer_state (void *s_,
......
......@@ -105,6 +105,7 @@ int zmq_poller_wait_all (void *poller_,
zmq_poller_event_t *events_,
int n_events_,
long timeout_);
int zmq_poller_fd (void *poller_);
#if defined _WIN32
int zmq_poller_add_fd (void *poller_,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment