|
Sese Framework
3.0.0
A cross-platform framework
|
Time Wheel. More...
#include <TimeWheel.h>
Public Member Functions | |
| TimeWheel () | |
| virtual | ~TimeWheel () |
| TimeoutEvent * | delay (const TimeoutEvent::Callback &callback, int64_t seconds, bool repeat=false) |
| void | cancel (TimeoutEvent *event) |
| void | check () |
| Check for any timeout events that need to be triggered, and trigger the corresponding callback functions and destroy the events as needed. | |
Static Protected Member Functions | |
| static int64_t | getTimestamp () |
Protected Attributes | |
| int64_t | startTime {} |
| int64_t | lastCheckTime {} |
| TimeoutEventSlot | slots [60] {} |
Time Wheel.
| TimeWheel::TimeWheel | ( | ) |
|
virtual |
References slots.
| void TimeWheel::cancel | ( | TimeoutEvent * | event | ) |
Cancel a timeout event, making it unavailable
| event | Timeout event |
References sese::TimeoutEventSlot::events, slots, and startTime.
| void TimeWheel::check | ( | ) |
Check for any timeout events that need to be triggered, and trigger the corresponding callback functions and destroy the events as needed.
References EVENT, sese::TimeoutEventSlot::events, getTimestamp(), lastCheckTime, slots, and startTime.
| TimeoutEvent * TimeWheel::delay | ( | const TimeoutEvent::Callback & | callback, |
| int64_t | seconds, | ||
| bool | repeat = false ) |
Add a timeout event
| callback | Timeout callback function |
| seconds | Timeout duration |
| repeat | Whether the event triggers repeatedly |
References sese::TimeoutEventSlot::events, getTimestamp(), sese::TimeoutEvent::range, slots, and startTime.
|
staticprotected |
Referenced by check(), delay(), and TimeWheel().
|
protected |
Referenced by check(), and TimeWheel().
|
protected |
Referenced by cancel(), check(), delay(), TimeWheel(), and ~TimeWheel().
|
protected |
Referenced by cancel(), check(), delay(), and TimeWheel().