主要的函数声明:
-
TAILQ_HEAD (event_list, event); //声明event_list为event链表的头节点
声明一个event链表的头部结构,名称是event_list, 该结构在event_base的声明中被使用
-
TAILQ_HEAD (evkeyvalq, evkeyval); //定义evkeyvalq为evkeyval链表的头节点
-
struct event_base *event_base_new(void) //创建一个event_base
该函数被event_init()函数调用
-
struct event_base *event_init(void) //创建一个event_base对象base,并把创建的base赋给全局event_struct对象current_base
该函数直接被应用系统调用
-
int event_reinit(struct event_base *base)
事件分发
该函数直接被应用系统调用
-
int event_base_dispatch(struct event_base *)
事件分发,开始某个指定的event_base的主循环
该函数直接被应用程序调用
-
const char *event_base_get_method(struct event_base *)
-
void event_base_free(struct event_base *)
释放指定event_base的所有占用的资源
该函数直接被应用程序调用
-
typedef void (*event_log_cb)(int severity, const char *msg)
声明日志回调函数类型
-
void event_set_log_callback(event_log_cb cb)
设定日志回调函数
-
int event_base_set(struct event_base *, struct event *)
绑定某个event到特定的event_base
该函数直接被应用程序调用
-
*///处理事件,与event_dispatch()类似
-
int event_loop(int)
该函数被event_dispatch函数调用
-
int event_base_loop(struct event_base *, int)
该函数被event_base_dispatch函数调用
-
*///指定时间后退出循环
-
int event_loopexit(const struct timeval *)
该函数直接被应用程序调用
-
*///指定时间后退出循环,线程安全的
-
int event_base_loopexit(struct event_base *, const struct timeval *)
该函数直接被应用程序调用
-
int event_loopbreak(void);//立即终止循环
该函数直接被应用程序调用
-
int event_base_loopbreak(struct event_base *);//立即终止循环,
该函数直接被应用程序调用
-
#define evtimer_add(ev, tv) event_add(ev, tv)//增加定时器事件
-
#define evtimer_set(ev, cb, arg) event_set(ev, -1, 0, cb, arg)//设置定时器时间
-
#define evtimer_del(ev) event_del(ev)//删除定时器事件
-
#define evtimer_pending(ev, tv) event_pending(ev, EV_TIMEOUT, tv)//event挂起
-
#define evtimer_initialized(ev) ((ev)->ev_flags & EVLIST_INIT) //判断该事件是不是初始化
-
#define timeout_add(ev, tv) event_add(ev, tv)//增加一个超时event
-
#define timeout_set(ev, cb, arg) event_set(ev, -1, 0, cb, arg)//设定一个超时event
-
#define timeout_del(ev) event_del(ev) //删除超时event
-
#define timeout_pending(ev, tv) event_pending(ev, EV_TIMEOUT, tv)
-
#define timeout_initialized(ev) ((ev)->ev_flags & EVLIST_INIT)
-
#define signal_add(ev, tv) event_add(ev, tv)
-
#define signal_set(ev, x, cb, arg) \
-
event_set(ev, x, EV_SIGNAL|EV_PERSIST, cb, arg)
-
#define signal_del(ev) event_del(ev)
-
#define signal_pending(ev, tv) event_pending(ev, EV_SIGNAL, tv)
-
#define signal_initialized(ev) ((ev)->ev_flags & EVLIST_INIT)
-
void event_set(struct event *, int, short, void (*)(int, short, void *), void *)
该函数直接被应用程序调用
-
int event_once(int, short, void (*)(int, short, void *), void *,
-
const struct timeval *)
-
int event_base_once(struct event_base *base, int fd, short events,
-
void (*callback)(int, short, void *), void *arg,
-
const struct timeval *timeout)
该函数被event_loopexit函数与event_base_loopexit函数调用
-
int event_add(struct event *ev, const struct timeval *timeout)
该函数直接被应用程序调用
-
int event_del(struct event *)
-
void event_active(struct event *, int, short)
-
int event_pending(struct event *ev, short event, struct timeval *tv)
-
#define event_initialized(ev) ((ev)->ev_flags & EVLIST_INIT)
-
const char *event_get_version(void)
-
const char *event_get_method(void)
-
int event_priority_init(int)
-
int event_base_priority_init(struct event_base *, int)
-
int event_priority_set(struct event *, int)
bufferevent
-
struct bufferevent *bufferevent_new(int fd,
-
evbuffercb readcb, evbuffercb writecb, everrorcb errorcb, void *cbarg)
-
int bufferevent_base_set(struct event_base *base, struct bufferevent *bufev)
-
int bufferevent_priority_set(struct bufferevent *bufev, int pri)
-
void bufferevent_free(struct bufferevent *bufev)
-
void bufferevent_setcb(struct bufferevent *bufev,
-
evbuffercb readcb, evbuffercb writecb, everrorcb errorcb, void *cbarg)
-
void bufferevent_setfd(struct bufferevent *bufev, int fd)
-
int bufferevent_write(struct bufferevent *bufev,
-
const void *data, size_t size)
-
int bufferevent_write_buffer(struct bufferevent *bufev, struct evbuffer *buf)
-
size_t bufferevent_read(struct bufferevent *bufev, void *data, size_t size)
-
int bufferevent_enable(struct bufferevent *bufev, short event)
-
int bufferevent_disable(struct bufferevent *bufev, short event)
-
void bufferevent_settimeout(struct bufferevent *bufev,
-
int timeout_read, int timeout_write)
-
void bufferevent_setwatermark(struct bufferevent *bufev, short events,
-
size_t lowmark, size_t highmark)
-
#define EVBUFFER_LENGTH(x) (x)->off
-
#define EVBUFFER_DATA(x) (x)->buffer
-
#define EVBUFFER_INPUT(x) (x)->input
-
#define EVBUFFER_OUTPUT(x) (x)->output
-
struct evbuffer *evbuffer_new(void)
-
void evbuffer_free(struct evbuffer *)
-
int evbuffer_expand(struct evbuffer *, size_t)
-
int evbuffer_add(struct evbuffer *, const void *, size_t)
-
int evbuffer_remove(struct evbuffer *, void *, size_t)
-
char *evbuffer_readline(struct evbuffer *)
-
/** Used to tell evbuffer_readln what kind of line-ending to look for.
-
*/
-
enum evbuffer_eol_style {
-
/** Any sequence of CR and LF characters is acceptable as an EOL. */
-
EVBUFFER_EOL_ANY,
-
/** An EOL is an LF, optionally preceded by a CR. This style is
-
* most useful for implementing text-based internet protocols. */
-
EVBUFFER_EOL_CRLF,
-
/** An EOL is a CR followed by an LF. */
-
EVBUFFER_EOL_CRLF_STRICT,
-
/** An EOL is a LF. */
-
EVBUFFER_EOL_LF
-
}
-
char *evbuffer_readln(struct evbuffer *buffer, size_t *n_read_out,
-
enum evbuffer_eol_style eol_style)
-
int evbuffer_add_buffer(struct evbuffer *, struct evbuffer *)
-
int evbuffer_add_vprintf(struct evbuffer *, const char *fmt, va_list ap)
-
void evbuffer_drain(struct evbuffer *, size_t)
-
int evbuffer_write(struct evbuffer *, int)
-
int evbuffer_read(struct evbuffer *, int, int)
-
u_char *evbuffer_find(struct evbuffer *, const u_char *, size_t)
-
void evbuffer_setcb(struct evbuffer *, void (*)(struct evbuffer *, size_t, size_t, void *), void *)
-
void evtag_marshal(struct evbuffer *evbuf, ev_uint32_t tag, const void *data,
-
ev_uint32_t len)
-
void encode_int(struct evbuffer *evbuf, ev_uint32_t number)
-
void evtag_marshal_int(struct evbuffer *evbuf, ev_uint32_t tag,
-
ev_uint32_t integer);
-
-
void evtag_marshal_string(struct evbuffer *buf, ev_uint32_t tag,
-
const char *string);
-
-
void evtag_marshal_timeval(struct evbuffer *evbuf, ev_uint32_t tag,
-
struct timeval *tv);
-
-
int evtag_unmarshal(st
阅读(945) | 评论(0) | 转发(0) |