InspIRCd  3.0
Public Member Functions | List of all members
Timer Class Referenceabstract

#include <timer.h>

Inheritance diagram for Timer:
SocketTimeout

Public Member Functions

 Timer (unsigned int secs_from_now, bool repeating=false)
 
virtual ~Timer ()
 
time_t GetTrigger () const
 
void SetTrigger (time_t nexttrigger)
 
void SetInterval (time_t interval)
 
virtual bool Tick (time_t TIME)=0
 
bool GetRepeat () const
 
unsigned int GetInterval () const
 
void CancelRepeat ()
 

Detailed Description

Timer class for one-second resolution timers Timer provides a facility which allows module developers to create one-shot timers. The timer can be made to trigger at any time up to a one-second resolution. To use Timer, inherit a class from Timer, then insert your inherited class into the queue using Server::AddTimer(). The Tick() method of your object (which you have to override) will be called at the given time.

Constructor & Destructor Documentation

◆ Timer()

Timer::Timer ( unsigned int  secs_from_now,
bool  repeating = false 
)

Default constructor, initializes the triggering time

Parameters
secs_from_nowThe number of seconds from now to trigger the timer
repeatingRepeat this timer every secs_from_now seconds if set to true

◆ ~Timer()

Timer::~Timer ( )
virtual

Default destructor, removes the timer from the timer manager

Member Function Documentation

◆ CancelRepeat()

void Timer::CancelRepeat ( )
inline

Cancels the repeat state of a repeating timer. If you call this method, then the next time your timer ticks, it will be removed immediately after.

◆ GetInterval()

unsigned int Timer::GetInterval ( ) const
inline

Returns the interval (number of seconds between ticks) of this timer object.

◆ GetRepeat()

bool Timer::GetRepeat ( ) const
inline

Returns true if this timer is set to repeat

◆ GetTrigger()

time_t Timer::GetTrigger ( ) const
inline

Retrieve the current triggering time

◆ SetInterval()

void Timer::SetInterval ( time_t  interval)

Sets the interval between two ticks.

◆ SetTrigger()

void Timer::SetTrigger ( time_t  nexttrigger)
inline

Sets the trigger timeout to a new value This does not update the bookkeeping in TimerManager, use SetInterval() to change the interval between ticks while keeping TimerManager updated

◆ Tick()

virtual bool Timer::Tick ( time_t  TIME)
pure virtual

Called when the timer ticks. You should override this method with some useful code to handle the tick event.

Parameters
TIMEThe current time.
Returns
True if the Timer object is still valid, false if it was destructed.

Implemented in SocketTimeout.


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