mirror of
https://github.com/zeromq/libzmq.git
synced 2025-01-14 09:47:56 +08:00
Rename zmq_monitor to zmq_ctx_set_monitor for compat with existing context specific APIs
This commit is contained in:
parent
04f0e7f26e
commit
991b7fcc04
@ -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 \
|
||||
|
@ -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':
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user