linux event事件机制,libevent的事件机制

struct eventop {

/** The name of this backend. */

const char *name;

/** Function to set up an event_base to use this backend. It should

* create a new structure holding whatever information is needed to

* run the backend, and return it. The returned pointer will get

* stored by event_init into the event_base.evbase field. On failure,

* this function should return NULL. */

void *(*init)(struct event_base *);

/** Enable reading/writing on a given fd or signal. 'events' will be

* the events that we're trying to enable: one or more of EV_READ,

* EV_WRITE, EV_SIGNAL, and EV_ET. 'old' will be those events that

* were enabled on this fd previously. 'fdinfo' will be a structure

* associated with the fd by the evmap; its size is defined by the

* fdinfo field below. It will be set to 0 the first time the fd is

* added. The function should return 0 on success and -1 on error.

*/

int (*add)(struct event_base *, evutil_socket_t fd, short old, short events, void *fdinfo);

/** As "add", except 'events' contains the events we mean to disable. */

int (*del)(struct event_base *, evutil_socket_t fd, short old, short events, void *fdinfo);

/** Function to implement the core of an event loop. It must see which

added events are ready, and cause event_active to be called for each

active event (usually via event_io_active or such). It should

return 0 on success and -1 on error.

*/

int (*dispatch)(struct event_base *, struct timeval *);

/** Function to clean up and free our data from the event_base. */

void (*dealloc)(struct event_base *);

/** Flag: set if we need to reinitialize the event base after we fork.

*/

int need_reinit;

/** Bit-array of supported event_method_features that this backend can

* provide. */

enum event_method_feature features;

/** Length of the extra information we should record for each fd that

has one or more active events. This information is recorded

as part of the evmap entry for each fd, and passed as an argument

to the add and del functions above.

*/

size_t fdinfo_len;

};

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值