17#include <trantor/net/EventLoop.h>
19#include <trantor/exports.h>
25#include <unordered_map>
26#include <unordered_set>
30#define TIMING_BUCKET_NUM_PER_WHEEL 100
31#define TIMING_TICK_INTERVAL 1.0
35using EntryPtr = std::shared_ptr<void>;
37using EntryBucket = std::unordered_set<EntryPtr>;
38using BucketQueue = std::deque<EntryBucket>;
51 CallbackEntry(std::function<
void()> cb) : cb_(std::move(cb))
60 std::function<void()> cb_;
79 float ticksInterval = TIMING_TICK_INTERVAL,
80 size_t bucketsNumPerWheel = TIMING_BUCKET_NUM_PER_WHEEL);
82 void insertEntry(
size_t delay, EntryPtr entryPtr);
84 void insertEntryInloop(
size_t delay, EntryPtr entryPtr);
94 std::vector<BucketQueue> wheels_;
96 std::atomic<size_t> ticksCounter_{0};
98 trantor::TimerId timerId_;
101 float ticksInterval_;
103 size_t bucketsNumPerWheel_;
As the name implies, this class represents an event loop that runs in a particular thread....
Definition EventLoop.h:56
This class implements a timer strategy with high performance and low accuracy. This is usually used i...
Definition TimingWheel.h:46
TimingWheel(trantor::EventLoop *loop, size_t maxTimeout, float ticksInterval=TIMING_TICK_INTERVAL, size_t bucketsNumPerWheel=TIMING_BUCKET_NUM_PER_WHEEL)
Construct a new timing wheel instance.
Definition EventLoop.h:34