The current implementation of timers (zmq_timers) is quite hard to use (in my experience) and I think it would be better if we could have a "timer socket" which would behave like a regular socket but send a message at a regular interval.
(This might also be a nice fit for timerfd_create on Linux since that would integrate nicely with epoll)
Example
void *subscriber = zmq_socket(...);
void *timer = zmq_socket_timer(...);
int t = 1000;
zmq_setsockopt(timer, ZMQ_TIMER_INTERVAL, &t, sizeof t);
void *poller = zmq_poller_new();
zmq_poller_add(poller, subscriber, ...);
zmq_poller_add(timer, subscriber, ...);
for (;;)
{
zmq_poller_event_t event;
int ret = zmq_poller_wait(poller, &event, 100);
if (ret != -1) {
if (event.socket == subscriber)
// Something
else if (event.socket == timer)
// Somthing else
}
}
The current implementation of timers (
zmq_timers) is quite hard to use (in my experience) and I think it would be better if we could have a "timer socket" which would behave like a regular socket but send a message at a regular interval.(This might also be a nice fit for
timerfd_createon Linux since that would integrate nicely withepoll)Example