return &event_self_cbarg_ptr_;
}
+struct event *
+event_base_get_running_event(struct event_base *base)
+{
+ struct event *ev = NULL;
+ EVBASE_ACQUIRE_LOCK(base, th_base_lock);
+ if (EVBASE_IN_THREAD(base))
+ ev = base->current_event;
+ EVBASE_RELEASE_LOCK(base, th_base_lock);
+ return ev;
+}
+
struct event *
event_new(struct event_base *base, evutil_socket_t fd, short events, void (*cb)(evutil_socket_t, short, void *), void *arg)
{
*/
int event_pending(const struct event *ev, short events, struct timeval *tv);
+/**
+ If called from within the callback for an event, returns that event.
+
+ The behavior of this function is not defined when called from outside the
+ callback function for an event.
+ */
+struct event *event_base_get_running_event(struct event_base *base);
/**
Test if an event structure might be initialized.
struct event_base *base = event_get_base(ev);
event_base_assert_ok_(base);
event_base_loopexit(base, NULL);
+ tt_want(ev == event_base_get_running_event(base));
}
static void