Sese Framework  2.3.0
A cross-platform framework
Loading...
Searching...
No Matches
sese::TimeWheel Class Reference

Time Wheel. More...

#include <TimeWheel.h>

Public Member Functions

 TimeWheel ()
 
virtual ~TimeWheel ()
 
TimeoutEventdelay (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] {}
 

Detailed Description

Time Wheel.

Constructor & Destructor Documentation

◆ TimeWheel()

◆ ~TimeWheel()

TimeWheel::~TimeWheel ( )
virtual

References slots.

Member Function Documentation

◆ cancel()

void TimeWheel::cancel ( TimeoutEvent * event)

◆ check()

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().

◆ delay()

TimeoutEvent * TimeWheel::delay ( const TimeoutEvent::Callback & callback,
int64_t seconds,
bool repeat = false )

Add a timeout event

Parameters
callbackTimeout callback function
secondsTimeout duration
repeatWhether the event triggers repeatedly
Returns
Timeout event

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().

◆ getTimestamp()

int64_t TimeWheel::getTimestamp ( )
staticprotected

Referenced by check(), delay(), and TimeWheel().

Member Data Documentation

◆ lastCheckTime

int64_t sese::TimeWheel::lastCheckTime {}
protected

Referenced by check(), and TimeWheel().

◆ slots

TimeoutEventSlot sese::TimeWheel::slots[60] {}
protected

◆ startTime

int64_t sese::TimeWheel::startTime {}
protected

Referenced by cancel(), check(), delay(), and TimeWheel().


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