mirror of
https://gitee.com/Vancouver2017/luban-lite-t3e-pro.git
synced 2025-12-14 18:38:55 +00:00
3.4 KiB
3.4 KiB
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。 |
