0
0
mirror of https://github.com/zeromq/libzmq.git synced 2025-01-14 09:47:56 +08:00

drop the socket postfix from poller methods

This commit is contained in:
somdoron 2015-10-21 14:04:33 +03:00
parent 5c71fe6538
commit 24fc0d4e89
5 changed files with 20 additions and 20 deletions

View File

@ -447,9 +447,9 @@ typedef struct zmq_poller_event_t
ZMQ_EXPORT void *zmq_poller_new (); ZMQ_EXPORT void *zmq_poller_new ();
ZMQ_EXPORT int zmq_poller_close (void *poller); ZMQ_EXPORT int zmq_poller_close (void *poller);
ZMQ_EXPORT int zmq_poller_add_socket (void *poller, void *socket, void *user_data, short events); ZMQ_EXPORT int zmq_poller_add (void *poller, void *socket, void *user_data, short events);
ZMQ_EXPORT int zmq_poller_modify_socket (void *poller, void *socket, short events); ZMQ_EXPORT int zmq_poller_modify (void *poller, void *socket, short events);
ZMQ_EXPORT int zmq_poller_remove_socket (void *poller, void *socket); ZMQ_EXPORT int zmq_poller_remove (void *poller, void *socket);
ZMQ_EXPORT int zmq_poller_wait (void *poller, zmq_poller_event_t *event, long timeout); ZMQ_EXPORT int zmq_poller_wait (void *poller, zmq_poller_event_t *event, long timeout);
#if defined _WIN32 #if defined _WIN32
@ -458,7 +458,7 @@ ZMQ_EXPORT int zmq_poller_modify_fd (void *poller, SOCKET fd, short events);
ZMQ_EXPORT int zmq_poller_remove_fd (void *poller, SOCKET fd); ZMQ_EXPORT int zmq_poller_remove_fd (void *poller, SOCKET fd);
#else #else
ZMQ_EXPORT int zmq_poller_add_fd (void *poller, int fd, void *user_data, short events); ZMQ_EXPORT int zmq_poller_add_fd (void *poller, int fd, void *user_data, short events);
ZMQ_EXPORT int zmq_poller_modify (void *poller, int fd, short events); ZMQ_EXPORT int zmq_poller_modify_fd (void *poller, int fd, short events);
ZMQ_EXPORT int zmq_poller_remove_fd (void *poller, int fd); ZMQ_EXPORT int zmq_poller_remove_fd (void *poller, int fd);
#endif #endif

View File

@ -61,7 +61,7 @@ bool zmq::socket_poller_t::check_tag ()
return tag == 0xCAFEBABE; return tag == 0xCAFEBABE;
} }
int zmq::socket_poller_t::add_socket (void *socket_, void* user_data_, short events_) int zmq::socket_poller_t::add (void *socket_, void* user_data_, short events_)
{ {
for (events_t::iterator it = events.begin (); it != events.end (); ++it) { for (events_t::iterator it = events.begin (); it != events.end (); ++it) {
if (it->socket == socket_) { if (it->socket == socket_) {
@ -108,7 +108,7 @@ int zmq::socket_poller_t::add_fd (int fd_, void *user_data_, short events_)
return 0; return 0;
} }
int zmq::socket_poller_t::modify_socket (void *socket_, short events_) int zmq::socket_poller_t::modify (void *socket_, short events_)
{ {
events_t::iterator it; events_t::iterator it;
@ -154,7 +154,7 @@ int zmq::socket_poller_t::modify_fd (int fd_, short events_)
} }
int zmq::socket_poller_t::remove_socket (void* socket_) int zmq::socket_poller_t::remove (void* socket_)
{ {
events_t::iterator it; events_t::iterator it;

View File

@ -56,9 +56,9 @@ namespace zmq
short events; short events;
} event_t; } event_t;
int add_socket (void *socket, void *user_data, short events); int add (void *socket, void *user_data, short events);
int modify_socket (void *socket, short events); int modify (void *socket, short events);
int remove_socket (void *socket); int remove (void *socket);
#if defined _WIN32 #if defined _WIN32
int add_fd (SOCKET fd, void *user_data, short events); int add_fd (SOCKET fd, void *user_data, short events);
int modify_fd (SOCKET fd, short events); int modify_fd (SOCKET fd, short events);

View File

@ -1579,14 +1579,14 @@ int zmq_poller_close (void *poller_)
return 0; return 0;
} }
int zmq_poller_add_socket (void *poller_, void *socket_, void *user_data_, short events_) int zmq_poller_add (void *poller_, void *socket_, void *user_data_, short events_)
{ {
if (!poller_ || !((zmq::socket_poller_t*)poller_)->check_tag ()) { if (!poller_ || !((zmq::socket_poller_t*)poller_)->check_tag ()) {
errno = EFAULT; errno = EFAULT;
return -1; return -1;
} }
return ((zmq::socket_poller_t*)poller_)->add_socket (socket_, user_data_, events_); return ((zmq::socket_poller_t*)poller_)->add (socket_, user_data_, events_);
} }
#if defined _WIN32 #if defined _WIN32
@ -1604,14 +1604,14 @@ int zmq_poller_add_fd (void *poller_, int fd_, void *user_data_, short events_)
} }
int zmq_poller_modify_socket (void *poller_, void *socket_, short events_) int zmq_poller_modify (void *poller_, void *socket_, short events_)
{ {
if (!poller_ || !((zmq::socket_poller_t*)poller_)->check_tag ()) { if (!poller_ || !((zmq::socket_poller_t*)poller_)->check_tag ()) {
errno = EFAULT; errno = EFAULT;
return -1; return -1;
} }
return ((zmq::socket_poller_t*)poller_)->modify_socket (socket_, events_); return ((zmq::socket_poller_t*)poller_)->modify (socket_, events_);
} }
@ -1630,14 +1630,14 @@ int zmq_poller_modify_fd (void *poller_, int fd_, short events_)
} }
int zmq_poller_remove_socket (void *poller_, void *socket) int zmq_poller_remove (void *poller_, void *socket)
{ {
if (!poller_ || !((zmq::socket_poller_t*)poller_)->check_tag ()) { if (!poller_ || !((zmq::socket_poller_t*)poller_)->check_tag ()) {
errno = EFAULT; errno = EFAULT;
return -1; return -1;
} }
return ((zmq::socket_poller_t*)poller_)->remove_socket (socket); return ((zmq::socket_poller_t*)poller_)->remove (socket);
} }
#if defined _WIN32 #if defined _WIN32

View File

@ -61,7 +61,7 @@ int main (void)
// Set up poller // Set up poller
void* poller = zmq_poller_new (); void* poller = zmq_poller_new ();
rc = zmq_poller_add_socket (poller, sink, sink, ZMQ_POLLIN); rc = zmq_poller_add (poller, sink, sink, ZMQ_POLLIN);
assert (rc == 0); assert (rc == 0);
// Send a message // Send a message
@ -79,7 +79,7 @@ int main (void)
assert (rc == 1); assert (rc == 1);
// Stop polling sink // Stop polling sink
rc = zmq_poller_remove_socket (poller, sink); rc = zmq_poller_remove (poller, sink);
assert (rc == 0); assert (rc == 0);
// Check we can poll an FD // Check we can poll an FD
@ -106,7 +106,7 @@ int main (void)
zmq_poller_remove_fd (poller, fd); zmq_poller_remove_fd (poller, fd);
// Polling on thread safe sockets // Polling on thread safe sockets
rc = zmq_poller_add_socket (poller, server, NULL, ZMQ_POLLIN); rc = zmq_poller_add (poller, server, NULL, ZMQ_POLLIN);
assert (rc == 0); assert (rc == 0);
rc = zmq_connect (client, "tcp://127.0.0.1:55557"); rc = zmq_connect (client, "tcp://127.0.0.1:55557");
assert (rc == 0); assert (rc == 0);
@ -120,7 +120,7 @@ int main (void)
assert (rc == 1); assert (rc == 1);
// Polling on pollout // Polling on pollout
rc = zmq_poller_modify_socket (poller, server, ZMQ_POLLOUT | ZMQ_POLLIN); rc = zmq_poller_modify (poller, server, ZMQ_POLLOUT | ZMQ_POLLIN);
assert (rc == 0); assert (rc == 0);
rc = zmq_poller_wait (poller, &event, 0); rc = zmq_poller_wait (poller, &event, 0);
assert (rc == 0); assert (rc == 0);