int
main() {
        pipe(pp);
        struct event_base *base = event_base_new();
        evr = event_new(base, pp[0], EV_READ, read_cb, NULL);
        evw = event_new(base, pp[1], EV_WRITE  | EV_TIMEOUT, write_cb, NULL);

        event_add(evw, NULL);
        event_add(evr, NULL);

        struct event_base *outbase;
        int fdout;
        event_get_assignment(evw, NULL, &fdout, NULL, NULL, NULL);		/* Note fdout. */
        outbase = event_get_base(evw);		/* outbase == base */
        event_callback_fn cb = event_get_callback(evw);
        assert(write_cb == cb);
        assert(NULL == event_get_callback_arg(evw));

        assert(EV_WRITE|EV_TIMEOUT == event_get_events(evw));

        assert(pp[1] == event_get_fd(evw));
        assert(event_initialized(evw) == 1);

        test_num_events();
        event_base_dispatch(base);

        return 0;
}
Beispiel #2
0
 Timer::~Timer()
 {
     while ( !m_timers.empty() )
     {
         event* timer = m_timers.front();
         Data* data = ( Data* ) event_get_callback_arg( timer );
         delete data;
         event_free( timer );
         m_timers.pop_front();
     }
 }
Beispiel #3
0
void tgl_timer_free (struct tgl_timer *t) {
  void *arg = event_get_callback_arg ((void *)t);
  free (arg);
  event_free ((void *)t);
}