From e13b3723b8246b0526298698f9070d077b3322e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lourens=20Naud=C3=A9?= Date: Sun, 20 May 2012 18:27:59 +0100 Subject: [PATCH] Rename type zmq_monitor_fn -> zmq_monitor for a more natural callback definition API (zmq_monitor type, monitor.function callback) --- doc/zmq_getsockopt.txt | 2 +- doc/zmq_setsockopt.txt | 4 ++-- include/zmq.h | 2 +- src/options.cpp | 6 +++--- src/options.hpp | 4 ++-- tests/test_monitor.cpp | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/doc/zmq_getsockopt.txt b/doc/zmq_getsockopt.txt index e7ccd4a9..a2258411 100644 --- a/doc/zmq_getsockopt.txt +++ b/doc/zmq_getsockopt.txt @@ -461,7 +461,7 @@ Registers a callback function / event sink for changes in underlying socket stat The default value of `NULL` means no monitor callback function. [horizontal] -Option value type:: zmq_monitor_fn +Option value type:: zmq_monitor Option value unit:: N/A Default value:: no callback function Applicable socket types:: all diff --git a/doc/zmq_setsockopt.txt b/doc/zmq_setsockopt.txt index e291de35..d4a48ea7 100644 --- a/doc/zmq_setsockopt.txt +++ b/doc/zmq_setsockopt.txt @@ -434,7 +434,7 @@ Applicable socket types:: all listening sockets, when using TCP transports. ZMQ_MONITOR: Registers a callback for socket state changes ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Registers a callback function / event sink for changes in underlying socket state. -Expected signature of function member of zmq_monitor_fn union is `void (*function)(void *s, int event, zmq_event_data_t *data);` +Expected signature of function member of zmq_monitor union is `void (*function)(void *s, int event, zmq_event_data_t *data);` To remove the callback function call `zmq_setsockopt(socket, ZMQ_MONITOR, NULL, 0)` The default value of `NULL` means no monitor callback function. Supported events are : @@ -466,7 +466,7 @@ callback function as severe latency there will block the socket's application th Only tcp and ipc specific transport events are supported in this initial implementation. [horizontal] -Option value type:: zmq_monitor_fn +Option value type:: zmq_monitor Option value unit:: N/A Default value:: no callback function Applicable socket types:: all diff --git a/include/zmq.h b/include/zmq.h index 59cac8df..170bf70a 100644 --- a/include/zmq.h +++ b/include/zmq.h @@ -303,7 +303,7 @@ typedef union { typedef union { void *object; void (*function)(void *s, int event, zmq_event_data_t *data); -} zmq_monitor_fn; +} zmq_monitor; ZMQ_EXPORT void *zmq_socket (void *, int type); ZMQ_EXPORT int zmq_close (void *s); diff --git a/src/options.cpp b/src/options.cpp index d24834c1..82785e91 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -325,7 +325,7 @@ int zmq::options_t::setsockopt (int option_, const void *optval_, errno = EINVAL; return -1; } - monitor = *((zmq_monitor_fn**) &optval_); + monitor = *((zmq_monitor**) &optval_); return 0; } } @@ -550,8 +550,8 @@ int zmq::options_t::getsockopt (int option_, void *optval_, size_t *optvallen_) errno = EINVAL; return -1; } - *((zmq_monitor_fn**) &optval_) = monitor; - *optvallen_ = sizeof (zmq_monitor_fn*); + *((zmq_monitor**) &optval_) = monitor; + *optvallen_ = sizeof (zmq_monitor*); return 0; } diff --git a/src/options.hpp b/src/options.hpp index c1248c76..8ae134f8 100644 --- a/src/options.hpp +++ b/src/options.hpp @@ -125,8 +125,8 @@ namespace zmq typedef std::vector tcp_accept_filters_t; tcp_accept_filters_t tcp_accept_filters; - // Connection and exceptional state callback function - zmq_monitor_fn *monitor; + // Connection and exceptional state callback + zmq_monitor *monitor; // ID of the socket. int socket_id; diff --git a/tests/test_monitor.cpp b/tests/test_monitor.cpp index 5f31ebdd..049b1a9b 100644 --- a/tests/test_monitor.cpp +++ b/tests/test_monitor.cpp @@ -99,7 +99,7 @@ int main (int argc, char *argv []) assert (rep); // Expects failure - invalid size - zmq_monitor_fn monitor; + zmq_monitor monitor; monitor.function = listening_sock_monitor; rc = zmq_setsockopt (rep, ZMQ_MONITOR, &monitor, 20);