首页 > 代码库 > libevent源码分析:bufferevent

libevent源码分析:bufferevent

struct bufferevent定义在文件bufferevent_struct.h中。

 

 1 /** 2   Shared implementation of a bufferevent. 3  4   This type is exposed only because it was exposed in previous versions, 5   and some people‘s code may rely on manipulating it.  Otherwise, you 6   should really not rely on the layout, size, or contents of this structure: 7   it is fairly volatile, and WILL change in future versions of the code. 8 **/ 9 struct bufferevent {10     /** Event base for which this bufferevent was created. */11     struct event_base *ev_base;12     /** Pointer to a table of function pointers to set up how this13         bufferevent behaves. */14     const struct bufferevent_ops *be_ops;15 16     /** A read event that triggers when a timeout has happened or a socket17         is ready to read data.  Only used by some subtypes of18         bufferevent. */19     struct event ev_read;20     /** A write event that triggers when a timeout has happened or a socket21         is ready to write data.  Only used by some subtypes of22         bufferevent. */23     struct event ev_write;24 25     /** An input buffer. Only the bufferevent is allowed to add data to26         this buffer, though the user is allowed to drain it. */27     struct evbuffer *input;28 29     /** An input buffer. Only the bufferevent is allowed to drain data30         from this buffer, though the user is allowed to add it. */31     struct evbuffer *output;32 33     struct event_watermark wm_read;34     struct event_watermark wm_write;35 36     bufferevent_data_cb readcb;37     bufferevent_data_cb writecb;38     /* This should be called ‘eventcb‘, but renaming it would break39      * backward compatibility */40     bufferevent_event_cb errorcb;41     void *cbarg;42 43     struct timeval timeout_read;44     struct timeval timeout_write;45 46     /** Events that are currently enabled: currently EV_READ and EV_WRITE47         are supported. */48     short enabled;49 };

 

libevent源码分析:bufferevent