17 #ifndef CYBER_TIMER_TIMING_WHEEL_H_ 18 #define CYBER_TIMER_TIMING_WHEEL_H_ 36 static const uint64_t WORK_WHEEL_SIZE = 512;
37 static const uint64_t ASSISTANT_WHEEL_SIZE = 64;
38 static const uint64_t TIMER_RESOLUTION_MS = 2;
39 static const uint64_t TIMER_MAX_INTERVAL_MS =
40 WORK_WHEEL_SIZE * ASSISTANT_WHEEL_SIZE * TIMER_RESOLUTION_MS;
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_;
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_;
92 #endif // CYBER_TIMER_TIMING_WHEEL_H_
Definition: timing_wheel.h:42
Definition: timer_bucket.h:29
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
#define DECLARE_SINGLETON(classname)
Definition: macros.h:52
void Cascade(const uint64_t assistant_wheel_index)
uint64_t TickCount() const
Definition: timing_wheel.h:65
~TimingWheel()
Definition: timing_wheel.h:44
void AddTask(const std::shared_ptr< TimerTask > &task)