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

#include <timer.h>

Inheritance diagram for Timer:

Public Member Functions

 Timer (unsigned long secs_from_now, bool repeating=false)
virtual ~Timer ()
time_t GetTrigger () const
void SetTrigger (time_t nexttrigger)
void SetInterval (unsigned long interval)
virtual bool Tick (time_t TIME)=0
bool GetRepeat () const
unsigned long 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 long  secs_from_now,
bool  repeating = false 

Default constructor, initializes the triggering time

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

Default destructor, removes the timer from the timer manager

Member Function Documentation

◆ CancelRepeat()

void Timer::CancelRepeat ( )

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 long Timer::GetInterval ( ) const

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

◆ GetRepeat()

bool Timer::GetRepeat ( ) const

Returns true if this timer is set to repeat

◆ GetTrigger()

time_t Timer::GetTrigger ( ) const

Retrieve the current triggering time

◆ SetInterval()

void Timer::SetInterval ( unsigned long  interval)

Sets the interval between two ticks.

◆ SetTrigger()

void Timer::SetTrigger ( time_t  nexttrigger)

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.

TIMEThe current time.
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: