Skip to content

Instantly share code, notes, and snippets.

@lhope
Created August 18, 2013 07:35
Show Gist options
  • Save lhope/6260410 to your computer and use it in GitHub Desktop.
Save lhope/6260410 to your computer and use it in GitHub Desktop.
// Test exiting zloop using a timer.
#include <czmq.h>
// timeout using the boxed int.
int s_timeout (zloop_t *loop, zmq_pollitem_t *poller, void *arg)
{
int timeout = *((int*)arg);
zclock_sleep(timeout);
return -1;
}
int main (void)
{
int timeout[] = { 500 };
zloop_t *reactor = zloop_new ();
zloop_timer (reactor, 1000, 1, s_timeout, timeout);
zloop_start (reactor);
zloop_destroy (&reactor);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment