static int use_monotonic;
+static void *event_self_cbarg_ptr_ = NULL;
+
/* Prototypes */
static inline int event_add_internal(struct event *ev,
const struct timeval *tv, int tv_is_absolute);
EVUTIL_ASSERT(r == 0);
}
+void *
+event_self_cbarg(void)
+{
+ return &event_self_cbarg_ptr_;
+}
+
struct event *
event_new(struct event_base *base, evutil_socket_t fd, short events, void (*cb)(evutil_socket_t, short, void *), void *arg)
{
ev = mm_malloc(sizeof(struct event));
if (ev == NULL)
return (NULL);
+ if (arg == &event_self_cbarg_ptr_)
+ arg = ev;
if (event_assign(ev, base, fd, events, cb, arg) < 0) {
mm_free(ev);
return (NULL);
*/
typedef void (*event_callback_fn)(evutil_socket_t, short, void *);
+/**
+ Return a value used to specify that the event itself must be used as the callback argument.
+
+ The function event_new() takes a callback argument which is passed
+ to the event's callback function. To specify that the argument to be
+ passed to the callback function is the event that event_new() returns,
+ pass in the return value of event_self_cbarg() as the callback argument
+ for event_new().
+
+ For example:
+ <pre>
+ struct event *ev = event_new(base, sock, events, callback, %event_self_cbarg());
+ </pre>
+
+ @return a value to be passed as the callback argument to event_new().
+ @see event_new()
+ */
+void *event_self_cbarg(void);
+
/**
Allocate and asssign a new event structure, ready to be added.