int
event_base_dispatch(struct event_base *event_base)
{
return (event_base_loop(event_base, 0));
}
int event_base_loop(struct event_base *base, int flag);
flag取值:
EVLOOP_ONCE(0x01): 阻塞直到有一个活跃的event,然后执行完活跃事件的回调就退出。
EVLOOP_NONBLOCK (0x02): 不阻塞,检查哪个事件准备好,调用优先级最高的那一个,然后退出。没有事件准备好,就直接退出。这两个值执行一个事件。
EVLOOP_NO_EXIT_ON_EMPTY(0x04):阻塞,不退出,或者调用函数event_base_loopexit() or event_base_loopbreak()使得循环退出。和flag=0时不同,flag=0时,如果执行了disconnect的回调函数,循环就会结束。
如果成功返回0,如果发生错误返回-1,返回1则是没有事件注册。
int event_base_loopbreak(struct event_base *);
int event_base_loopexit(struct event_base *, const struct timeval *);
struct timeval
{
__time_t tv_sec; /* Seconds. */
__suseconds_t tv_usec; /* Microseconds. */
};
event_base_dispatch(struct event_base *event_base)
{
return (event_base_loop(event_base, 0));
}
int event_base_loop(struct event_base *base, int flag);
flag取值:
EVLOOP_ONCE(0x01): 阻塞直到有一个活跃的event,然后执行完活跃事件的回调就退出。
EVLOOP_NONBLOCK (0x02): 不阻塞,检查哪个事件准备好,调用优先级最高的那一个,然后退出。没有事件准备好,就直接退出。这两个值执行一个事件。
EVLOOP_NO_EXIT_ON_EMPTY(0x04):阻塞,不退出,或者调用函数event_base_loopexit() or event_base_loopbreak()使得循环退出。和flag=0时不同,flag=0时,如果执行了disconnect的回调函数,循环就会结束。
如果成功返回0,如果发生错误返回-1,返回1则是没有事件注册。
int event_base_loopbreak(struct event_base *);
int event_base_loopexit(struct event_base *, const struct timeval *);
struct timeval
{
__time_t tv_sec; /* Seconds. */
__suseconds_t tv_usec; /* Microseconds. */
};