This is a timer usage example ported from libevent.
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <fcntl.h>
#include <unistd.h>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cerrno>
#include <eventxx>
int called = 0;
#define NEVENT 20000
void
time_cb(int fd, short event, void *arg)
{
called++;
if (called < 10*NEVENT) {
for (int i = 0; i < 10; i++) {
int j = random() % NEVENT;
else
}
}
}
int
main (int argc, char **argv)
{
for (int i = 0; i < NEVENT; i++) {
}
return (called < NEVENT);
}
eventxx::timer< ccallback_type > ctimer
Shortcut to C-style timer.
Definition: eventxx:491
Event dispatcher.
Definition: eventxx:549
void del(basic_event &e)
Removes an event.
Definition: eventxx:738
int dispatch(int flags=0)
Main dispatcher loop.
Definition: eventxx:764
void add(basic_event &e, int priority=DEFAULT_PRIORITY)
Adds an event to the dispatcher.
Definition: eventxx:588
Time used for timeout values.
Definition: eventxx:111
long usec() const
Gets the number of microseconds.
Definition: eventxx:134
This is the specialization of eventxx::timer for C-style callbacks.
Definition: eventxx:395