struct event_base* event_base_new(void);
event_base_free(struct event_base* base);
event_base_dispatch(struct event_base* base);
const char **event_get_supported_methods();
const char * event_base_get_method(const struct event_base *base);
int event_reinit(struct event_base * base)
#define EV_TIMEOUT 0x01 // 废弃
#define EV_READ 0x02
#define EV_WRITE 0x04
#define EV_SIGNAL 0x08
#define EV_PERSIST 0x10 // 持续触发
#define EV_ET 0x20 // 边沿模式
typedef void(*event_callback_fn)(evutil_sockt_t,short,void *);
struct event *event_new(
struct event_base *base,
evutil_socket_t fd, // 文件描述符-int
shord what,
event_callback_fn cb, // 事件处理动作
void *arg
);
void event_free(struct event *event);
设置未决事件(有资格但是没有被处理的事件)
int event_add( struct event *ev, const struct timeval *tv );
int event_del(struct event *ev);
#define EVLOOP_ONCE 0x01
事件只会被触发一次
事件没有被触发, 阻塞等
#define EVLOOP_NONBLOCK 0x02
非阻塞 等方式去做事件检测
不关心事件是否被触发了
#define EVLOOP_NO_EXIT_ON_EMPTY 0x04
没有事件的时候, 也不退出轮询检测
event_base_dispatch(struct event_base* base)
struct timeval{
long tv_sec;
long tv_usec;
};
int event_base_loopexit(
struct event_base *base,
const struct timeval *tv
);
int event_base_loopbreak(struct event_base *base);
原文:https://www.cnblogs.com/joker-wz/p/10735410.html