ev.h
int ev_register_event(ev_context *ctx, int fd, int mask,
                      void (*callback)(ev_context *, void *), void *data) {
    ev_add_monitored(ctx, fd, mask, callback, data);
    int ret = 0;
    ret = ev_api_register_event(ctx, fd, mask);
    if (ret < 0) return EV_ERR;
    if (mask & EV_EVENTFD)
#ifdef __linux__
        (void) eventfd_write(fd, 1);
#else
        (void) write(fd, &(unsigned long){1}, sizeof(unsigned long));
#endif
    return EV_OK;
}
/*
 * Register a new event, semantically it's equal to ev_register_event but
 * it's meant to be used when an FD is not already watched by the event loop.
 * It could be easily integrated in ev_fire_event call but I prefer maintain
 * the samantic separation of responsibilities.
 *
 * Set a callback and an argument to be passed to for the next loop cycle,
 * associating it to a file descriptor, ultimately resulting in an event to be
 * dispatched and processed.
 *
 * The difference with ev_fire_event is that this function should be called
 * when the file descriptor is not registered in the loop yet.
 *
 * - mask: bitmask used to describe what type of event we're going to fire
 * - callback:  is a function pointer to the routine we want to execute
 * - data:  an opaque pointer to the arguments for the callback.
 */
Register a new event, semantically it's equal to ev_register_event but
it's meant to be used when an FD is not already watched by the event loop.
It could be easily integrated in ev_fire_event call but I prefer maintain
the samantic separation of responsibilities.

Set a callback and an argument to be passed to for the next loop cycle,
associating it to a file descriptor, ultimately resulting in an event to be
dispatched and processed.

The difference with ev_fire_event is that this function should be called
when the file descriptor is not registered in the loop yet.

- mask: bitmask used to describe what type of event we're going to fire
- callback:  is a function pointer to the routine we want to execute
- data:  an opaque pointer to the arguments for the callback.
Register a new event semantically it ' s equal to ev_register_event but it ' s meant to be used when an FD is not already watched by the event loop . It could be easily integrated in ev_fire_event call but I prefer maintain the samantic separation of responsibilities . Set a callback and an argument to be passed to for the next loop cycle associating it to a file descriptor ultimately resulting in an event to be dispatched and processed . The difference with ev_fire_event is that this function should be called when the file descriptor is not registered in the loop yet . - mask : bitmask used to describe what type of event we ' re going to fire - callback : is a function pointer to the routine we want to execute - data : an opaque pointer to the arguments for the callback .
int ev_register_event(ev_context *ctx, int fd, int mask,
                      void (*callback)(ev_context *, void *), void *data) {
    ev_add_monitored(ctx, fd, mask, callback, data);
    int ret = 0;
    ret = ev_api_register_event(ctx, fd, mask);
    if (ret < 0) return EV_ERR;
    if (mask & EV_EVENTFD)
#ifdef __linux__
        (void) eventfd_write(fd, 1);
#else
        (void) write(fd, &(unsigned long){1}, sizeof(unsigned long));
#endif
    return EV_OK;
}
int ev_register_event ( ev_context * ctx , int fd , int mask , void ( * callback ) ( ev_context * , void * ) , void * data ) { ev_add_monitored ( ctx , fd , mask , callback , data ) ; int ret = 0 ; ret = ev_api_register_event ( ctx , fd , mask ) ; if ( ret < 0 ) return EV_ERR ; if ( mask & EV_EVENTFD ) #ifdef __linux__ ( void ) eventfd_write ( fd , 1 ) ; #else ( void ) write ( fd , & ( unsigned long ) { 1 } , sizeof ( unsigned long ) ) ; #endif return EV_OK ; }
Register a new event, semantically it's equal to ev_register_event but
 it's meant to be used when an FD is not already watched by the event loop.
Register a new event semantically it ' s equal to ev_register_event but it ' s meant to be used when an FD is not already watched by the event loop .