Sese Framework
2.3.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.
Referenced by sese::_windows::iocp::v1::NativeIOCPServer::cancelTimeout(), sese::service::v2::TimerableService::cancelTimeoutEvent(), and sese::_windows::iocp::v1::NativeIOCPServer::releaseContext().
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.
Referenced by sese::_windows::iocp::v1::NativeIOCPServer::acceptThreadProc(), and sese::service::v2::TimerableService::dispatch().
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 callback(), sese::TimeoutEventSlot::events, getTimestamp(), sese::TimeoutEvent::range, slots, and startTime.
Referenced by sese::_windows::iocp::v1::NativeIOCPServer::setTimeout(), and sese::service::v2::TimerableService::setTimeoutEvent().
|
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().