Mercurial > MadButterfly
comparison include/mb_backend.h @ 1009:595a06fc0157 refine_backend_if
Change X_MB_add/remove_event() to match new mb_backend_t
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Mon, 22 Nov 2010 00:42:30 +0800 |
parents | 734ba9161be4 |
children | 02d52058d352 |
comparison
equal
deleted
inserted
replaced
1008:789f67288e1c | 1009:595a06fc0157 |
---|---|
20 | 20 |
21 typedef struct _mb_timer_man mb_timer_man_t; | 21 typedef struct _mb_timer_man mb_timer_man_t; |
22 typedef struct _mb_timer_factory mb_timer_factory_t; | 22 typedef struct _mb_timer_factory mb_timer_factory_t; |
23 typedef struct _mb_IO_man mb_IO_man_t; | 23 typedef struct _mb_IO_man mb_IO_man_t; |
24 typedef struct _mb_IO_factory mb_IO_factory_t; | 24 typedef struct _mb_IO_factory mb_IO_factory_t; |
25 typedef enum _MB_IO_TYPE MB_IO_TYPE; | |
25 | 26 |
26 /*! \brief The backend engine mb_backend_t is used to define the | 27 /*! \brief The backend engine mb_backend_t is used to define the |
27 * interface to realize the MB. | 28 * interface to realize the MB. |
28 * | 29 * |
29 * A backend is used to receive events from the system. The MB does | 30 * A backend is used to receive events from the system. The MB does |
43 void (*free)(mb_rt_t *rt); | 44 void (*free)(mb_rt_t *rt); |
44 /*! \brief Request the backend to start monitoring a file descriptor. | 45 /*! \brief Request the backend to start monitoring a file descriptor. |
45 * | 46 * |
46 * This is used only when the backend is responsible for event loop. | 47 * This is used only when the backend is responsible for event loop. |
47 */ | 48 */ |
48 void (*add_event)(mb_rt_t *rt,int type, int fd, mb_eventcb_t f,void *arg); | 49 int (*add_event)(mb_rt_t *rt, int fd, MB_IO_TYPE type, |
50 mb_eventcb_t f,void *arg); | |
49 /*! \brief Request the backend to stop monitoring a file descriptor. | 51 /*! \brief Request the backend to stop monitoring a file descriptor. |
50 * | 52 * |
51 * This is used only when the backend is responsible for event loop. | 53 * This is used only when the backend is responsible for event loop. |
52 */ | 54 */ |
53 void (*remove_event)(mb_rt_t *rt,int type, int fd); | 55 void (*remove_event)(mb_rt_t *rt, int hdl); |
54 /*! \brief Event Loop | 56 /*! \brief Event Loop |
55 * | 57 * |
56 * This is called when main application does not handle event | 58 * This is called when main application does not handle event |
57 * loop. Or, it should register an IO factory (i.e \ref | 59 * loop. Or, it should register an IO factory (i.e \ref |
58 * mb_IO_factory_t) with the backend. | 60 * mb_IO_factory_t) with the backend. |
76 extern mb_backend_t backend; | 78 extern mb_backend_t backend; |
77 | 79 |
78 /*! \brief Type of IO that registered with an IO manager. | 80 /*! \brief Type of IO that registered with an IO manager. |
79 */ | 81 */ |
80 enum _MB_IO_TYPE {MB_IO_DUMMY, MB_IO_R, MB_IO_W, MB_IO_RW}; | 82 enum _MB_IO_TYPE {MB_IO_DUMMY, MB_IO_R, MB_IO_W, MB_IO_RW}; |
81 typedef enum _MB_IO_TYPE MB_IO_TYPE; | |
82 | 83 |
83 /*! \brief Function signature of callback functions for IO requests. | 84 /*! \brief Function signature of callback functions for IO requests. |
84 */ | 85 */ |
85 typedef void (*mb_IO_cb_t)(int hdl, int fd, MB_IO_TYPE type, void *data); | 86 typedef void (*mb_IO_cb_t)(int hdl, int fd, MB_IO_TYPE type, void *data); |
86 | 87 |