56 void AddTask(
const std::shared_ptr<TimerTask>& task);
58 void AddTask(
const std::shared_ptr<TimerTask>& task,
59 const uint64_t current_work_wheel_index);
61 void Cascade(
const uint64_t assistant_wheel_index);
65 inline uint64_t
TickCount()
const {
return tick_count_; }
68 inline uint64_t GetWorkWheelIndex(
const uint64_t index) {
69 return index & (WORK_WHEEL_SIZE - 1);
71 inline uint64_t GetAssistantWheelIndex(
const uint64_t index) {
72 return index & (ASSISTANT_WHEEL_SIZE - 1);
75 bool running_ =
false;
76 uint64_t tick_count_ = 0;
77 std::mutex running_mutex_;
78 TimerBucket work_wheel_[WORK_WHEEL_SIZE];
79 TimerBucket assistant_wheel_[ASSISTANT_WHEEL_SIZE];
80 uint64_t current_work_wheel_index_ = 0;
81 std::mutex current_work_wheel_index_mutex_;
82 uint64_t current_assistant_wheel_index_ = 0;
83 std::mutex current_assistant_wheel_index_mutex_;
84 std::thread tick_thread_;