0
0
mirror of https://github.com/zeromq/libzmq.git synced 2024-12-27 15:41:05 +08:00

Problem: zmq timers API is not CLASS conformant

If we're going to add CLASS-like APIs we should use the proper
syntax; specifically 'destroy' instead of 'close', which is a
hangover from the 'ZeroMQ is like sockets' model we're slowly
moving away from.

Solution: change zmq_timers_close(p) to zmq_timers_destroy(&p)
This commit is contained in:
Pieter Hintjens 2015-12-21 10:56:37 +01:00
parent 627809568b
commit f8b9ca5f42
3 changed files with 8 additions and 7 deletions

View File

@ -457,8 +457,8 @@ ZMQ_EXPORT int zmq_poller_remove_fd (void *poller, int fd);
typedef void (zmq_timer_fn)(int timer_id, void *arg);
ZMQ_EXPORT void *zmq_timers_new ();
ZMQ_EXPORT int zmq_timers_close (void *timers);
ZMQ_EXPORT void *zmq_timers_new (void);
ZMQ_EXPORT int zmq_timers_destroy (void **timers);
ZMQ_EXPORT int zmq_timers_add (void *timers, size_t interval, zmq_timer_fn handler, void *arg);
ZMQ_EXPORT int zmq_timers_cancel (void *timers, int timer_id);
ZMQ_EXPORT int zmq_timers_set_interval (void *timers, int timer_id, size_t interval);

View File

@ -1185,14 +1185,15 @@ void *zmq_timers_new ()
return timers;
}
int zmq_timers_close (void *timers_)
int zmq_timers_destroy (void **timers_p_)
{
if (!timers_ || !((zmq::timers_t*)timers_)->check_tag ()) {
void *timers = *timers_p_;
if (!timers || !((zmq::timers_t *) timers)->check_tag ()) {
errno = EFAULT;
return -1;
}
delete ((zmq::timers_t*)timers_);
delete ((zmq::timers_t *) timers);
*timers_p_ = NULL;
return 0;
}

View File

@ -119,7 +119,7 @@ int main (void)
assert (rc == 0);
assert (!timer_invoked);
rc = zmq_timers_close (timers);
rc = zmq_timers_destroy (&timers);
assert (rc == 0);
return 0;