trantor
Non-blocking I/O cross-platform TCP network library, using C++14
Loading...
Searching...
No Matches
trantor::TimingWheel Class Reference

This class implements a timer strategy with high performance and low accuracy. This is usually used internally. More...

#include <trantor/utils/TimingWheel.h>

Classes

class  CallbackEntry

Public Member Functions

 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.
void insertEntry (size_t delay, EntryPtr entryPtr)
void insertEntryInloop (size_t delay, EntryPtr entryPtr)
EventLoopgetLoop ()

Detailed Description

This class implements a timer strategy with high performance and low accuracy. This is usually used internally.

Constructor & Destructor Documentation

◆ TimingWheel()

trantor::TimingWheel::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.

Parameters
loopThe event loop in which the timing wheel runs.
maxTimeoutThe maximum timeout of the timing wheel.
ticksIntervalThe internal timer tick interval. It affects the accuracy of the timing wheel.
bucketsNumPerWheelThe number of buckets per wheel.
Note
The max delay of the timing wheel is about ticksInterval*(bucketsNumPerWheel^wheelsNum) seconds.
Example: Four wheels with 200 buckets per wheel means the timing wheel can work with a timeout up to 200^4 seconds, about 50 years;

The documentation for this class was generated from the following file: