From 991b7fcc04de7d694dc54430c43f6bb01494086a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lourens=20Naud=C3=A9?= Date: Tue, 22 May 2012 20:15:18 +0100 Subject: [PATCH] Rename zmq_monitor to zmq_ctx_set_monitor for compat with existing context specific APIs --- doc/Makefile.am | 2 +- doc/zmq.txt | 2 +- doc/zmq_monitor.txt | 18 +++++++++--------- include/zmq.h | 2 +- src/zmq.cpp | 2 +- tests/test_monitor.cpp | 2 +- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/doc/Makefile.am b/doc/Makefile.am index 58c84aa7..eb75e62d 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -1,6 +1,6 @@ MAN3 = zmq_bind.3 zmq_close.3 zmq_connect.3 zmq_device.3 \ zmq_ctx_new.3 zmq_ctx_destroy.3 zmq_ctx_get.3 zmq_ctx_set.3 \ - zmq_init.3 zmq_term.3 zmq_monitor.3\ + zmq_init.3 zmq_term.3 zmq_ctx_set_monitor.3\ zmq_msg_close.3 zmq_msg_copy.3 zmq_msg_data.3 zmq_msg_init.3 \ zmq_msg_init_data.3 zmq_msg_init_size.3 zmq_msg_move.3 zmq_msg_size.3 \ zmq_msg_send.3 zmq_msg_recv.3 \ diff --git a/doc/zmq.txt b/doc/zmq.txt index a2635874..5370e7de 100644 --- a/doc/zmq.txt +++ b/doc/zmq.txt @@ -45,7 +45,7 @@ Destroy a 0MQ context:: linkzmq:zmq_ctx_destroy[3] Monitor a 0MQ context:: - linkzmq:zmq_monitor[3] + linkzmq:zmq_ctx_set_monitor[3] These deprecated functions let you create and destroy 'contexts': diff --git a/doc/zmq_monitor.txt b/doc/zmq_monitor.txt index 1570f5ba..c72fe921 100644 --- a/doc/zmq_monitor.txt +++ b/doc/zmq_monitor.txt @@ -1,25 +1,25 @@ -zmq_monitor(3) -============== +zmq_ctx_set_monitor(3) +====================== NAME ---- -zmq_monitor - register a monitoring callback +zmq_ctx_set_monitor - register a monitoring callback SYNOPSIS -------- -*int zmq_monitor (void '*context', zmq_monitor_fn '*monitor');* +*int zmq_ctx_set_monitor (void '*context', zmq_monitor_fn '*monitor');* DESCRIPTION ----------- -The _zmq_monitor()_ function shall register a callback function specified by +The _zmq_ctx_set_monitor()_ function shall register a callback function specified by the 'monitor' argument. This is an event sink for changes in per socket connection and mailbox (work in progress) states. -.The _zmq_monitor()_ callback function is expected to have this prototype: +.The _zmq_ctx_set_monitor()_ callback function is expected to have this prototype: ---- typedef void (zmq_monitor_fn) (void *s, int event, zmq_event_data_t *data); ---- @@ -28,7 +28,7 @@ The callback is global (per context), with the socket that triggered the event passed to the handler as well. Each event also populates a 'zmq_event_data_t' union with additional metadata which can be used for correlation. -CAUTION: _zmq_monitor()_ is intended for monitoring infrastructure / operations +CAUTION: _zmq_ctx_set_monitor()_ is intended for monitoring infrastructure / operations concerns only - NOT BUSINESS LOGIC. An event is a representation of something that happened - you cannot change the past, but only react to them. The implementation is also only concerned with a single session. No state of peers, @@ -158,7 +158,7 @@ data.disconnected.fd // socket descriptor RETURN VALUE ------------ -The _zmq_monitor()_ function returns a value of 0 or greater if successful. +The _zmq_ctx_set_monitor()_ function returns a value of 0 or greater if successful. Otherwise it returns `-1` and sets 'errno' to one of the values defined below. @@ -188,7 +188,7 @@ void socket_monitor (void *s, int event_, zmq_event_data_t *data_) } void *context = zmq_ctx_new (); -int rc = zmq_monitor (context, socket_monitor); +int rc = zmq_ctx_set_monitor (context, socket_monitor); assert (rc == 0); void *pub = zmq_socket (context, ZMQ_PUB); assert (pub); diff --git a/include/zmq.h b/include/zmq.h index b3146b20..83f9209a 100644 --- a/include/zmq.h +++ b/include/zmq.h @@ -301,7 +301,7 @@ typedef union { /* Callback template for socket state changes */ typedef void (zmq_monitor_fn) (void *s, int event, zmq_event_data_t *data); -ZMQ_EXPORT int zmq_monitor (void *context, zmq_monitor_fn *monitor); +ZMQ_EXPORT int zmq_ctx_set_monitor (void *context, zmq_monitor_fn *monitor); ZMQ_EXPORT void *zmq_socket (void *, int type); ZMQ_EXPORT int zmq_close (void *s); diff --git a/src/zmq.cpp b/src/zmq.cpp index 2f307c4a..a9de5ecb 100644 --- a/src/zmq.cpp +++ b/src/zmq.cpp @@ -205,7 +205,7 @@ int zmq_ctx_get (void *ctx_, int option_) return ((zmq::ctx_t*) ctx_)->get (option_); } -int zmq_monitor (void *ctx_, zmq_monitor_fn *monitor_) +int zmq_ctx_set_monitor (void *ctx_, zmq_monitor_fn *monitor_) { if (!ctx_ || !((zmq::ctx_t*) ctx_)->check_tag ()) { errno = EFAULT; diff --git a/tests/test_monitor.cpp b/tests/test_monitor.cpp index 4b50d904..394d6a5d 100644 --- a/tests/test_monitor.cpp +++ b/tests/test_monitor.cpp @@ -84,7 +84,7 @@ int main (int argc, char *argv []) void *ctx = zmq_init (1); assert (ctx); // set socket monitor - rc = zmq_monitor (ctx, socket_monitor); + rc = zmq_ctx_set_monitor (ctx, socket_monitor); assert (rc == 0); void *rep = zmq_socket (ctx, ZMQ_REP); assert (rep);