## event\_source\_t ### 概述  表示一个事件源。 事件源有下列两种方式: * 对于有文件描述符的事件源(如socket),get_fd返回一个有效的文件描述符。 * 对于定时器,则get_wakeup_time返回下次唤醒的时间。 ---------------------------------- ### 函数
| 函数名称 | 说明 | | -------- | ------------ | | event\_source\_check | 对于没有文件描述符的事件源,需要自己检查是否准备就绪。 | | event\_source\_dispatch | 分发事件。 | | event\_source\_get\_fd | 获取文件描述符。 | | event\_source\_get\_wakeup\_time | 获取唤醒时间(ms)。 | | event\_source\_set\_tag | 设置tag,方便通过tag一次移除多个事件源。 | #### event\_source\_check 函数 ----------------------- * 函数功能: >
对于没有文件描述符的事件源,需要自己检查是否准备就绪。 * 函数原型: ``` ret_t event_source_check (event_source_t* source); ``` * 参数说明: | 参数 | 类型 | 说明 | | -------- | ----- | --------- | | 返回值 | ret\_t | 返回RET\_OK表示成功,否则表示失败。 | | source | event\_source\_t* | event\_source对象。 | #### event\_source\_dispatch 函数 ----------------------- * 函数功能: >
分发事件。 * 函数原型: ``` ret_t event_source_dispatch (event_source_t* source); ``` * 参数说明: | 参数 | 类型 | 说明 | | -------- | ----- | --------- | | 返回值 | ret\_t | 返回RET\_OK表示成功,否则表示失败。 | | source | event\_source\_t* | event\_source对象。 | #### event\_source\_get\_fd 函数 ----------------------- * 函数功能: >
获取文件描述符。 * 函数原型: ``` int32_t event_source_get_fd (event_source_t* source); ``` * 参数说明: | 参数 | 类型 | 说明 | | -------- | ----- | --------- | | 返回值 | int32\_t | 返回文件描述符。 | | source | event\_source\_t* | event\_source对象。 | #### event\_source\_get\_wakeup\_time 函数 ----------------------- * 函数功能: >
获取唤醒时间(ms)。 * 函数原型: ``` uint32_t event_source_get_wakeup_time (event_source_t* source); ``` * 参数说明: | 参数 | 类型 | 说明 | | -------- | ----- | --------- | | 返回值 | uint32\_t | 返回唤醒时间(ms)。 | | source | event\_source\_t* | event\_source对象。 | #### event\_source\_set\_tag 函数 ----------------------- * 函数功能: >
设置tag,方便通过tag一次移除多个事件源。 * 函数原型: ``` ret_t event_source_set_tag (event_source_t* source, void* tag); ``` * 参数说明: | 参数 | 类型 | 说明 | | -------- | ----- | --------- | | 返回值 | ret\_t | 返回RET\_OK表示成功,否则表示失败。 | | source | event\_source\_t* | event\_source对象。 | | tag | void* | tag。 |