|
ngl_server 1.0
基于 Actor 模型的 C++ 服务器框架
|
时间轮节点 More...
#include <tools_time_wheel.h>
Public Types | |
| using | timecallback = std::function<void(wheel_node*)> |
| 时间回调函数类型 | |
Public Member Functions | |
| wheel_node (time_wheel *atw, int64_t atimerid, const std::shared_ptr< std::atomic_bool > &aremove, const wheel_parm &aparm) | |
| 构造函数 | |
| wheel_node (const wheel_node &aparm) | |
| 拷贝构造函数 | |
| bool | removed () const |
| 检查节点是否已移除 | |
Public Attributes | |
| time_wheel * | m_tw = nullptr |
| 所属时间轮指针 | |
| int64_t | m_timerid = 0 |
| 定时器唯一标识 | |
| std::shared_ptr< std::atomic_bool > | m_remove |
| 移除标志 | |
| wheel_node * | m_next = nullptr |
| 链表下一个节点 | |
| wheel_parm | m_parm |
| 定时器参数 | |
时间轮节点
表示时间轮中的一个定时器节点,包含定时器参数和状态信息。
| using ngl::tools::wheel_node::timecallback = std::function<void(wheel_node*)> |
时间回调函数类型
| node | 时间轮节点指针 |
| ngl::tools::wheel_node::wheel_node | ( | time_wheel * | atw, |
| int64_t | atimerid, | ||
| const std::shared_ptr< std::atomic_bool > & | aremove, | ||
| const wheel_parm & | aparm ) |
构造函数
wheel_node构造函数
| atw | 所属时间轮指针 |
| atimerid | 定时器ID |
| aremove | 移除标志 |
| aparm | 定时器参数 |
| atw | 所属时间轮指针 |
| atimerid | 定时器唯一ID |
| aremove | 取消标志的共享指针 |
| aparm | 定时器参数 |
| ngl::tools::wheel_node::wheel_node | ( | const wheel_node & | aparm | ) |
拷贝构造函数
wheel_node拷贝构造函数
| aparm | 源节点 |
用于重复定时器的克隆,m_next置为nullptr
| aparm | 源节点 |
|
inline |
检查节点是否已移除
| std::shared_ptr<std::atomic_bool> ngl::tools::wheel_node::m_remove |
移除标志
重复定时器的副本共享此标志,因此一次remove操作会取消所有未来的触发。