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

#include <timer.h>

Inheritance diagram for Timer:
CacheTimer RequestTimeout SocketTimeout

Public Member Functions

 Timer (long secs_from_now, time_t now, bool repeating=false)
virtual ~Timer ()
virtual time_t GetTimer ()
virtual void SetTimer (time_t t)
virtual void Tick (time_t TIME)=0
bool GetRepeat ()
long GetSecs ()
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 should override) will be called at the given time.

Constructor & Destructor Documentation

◆ Timer()

Timer::Timer ( long  secs_from_now,
time_t  now,
bool  repeating = false 

Default constructor, initializes the triggering time

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

◆ ~Timer()

virtual Timer::~Timer ( )

Default destructor, does nothing.

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. You should use this method call to remove a recurring timer if you wish to do so within the timer's Tick event, as calling TimerManager::DelTimer() from within the Timer::Tick() method is dangerous and may cause a segmentation fault. Calling CancelRepeat() is safe in this case.

◆ GetRepeat()

bool Timer::GetRepeat ( )

Returns true if this timer is set to repeat

◆ GetSecs()

long Timer::GetSecs ( )

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

◆ GetTimer()

virtual time_t Timer::GetTimer ( )

Retrieve the current triggering time

◆ SetTimer()

virtual void Timer::SetTimer ( time_t  t)

Sets the trigger timeout to a new value

◆ Tick()

virtual void 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.

Implemented in RequestTimeout, CacheTimer, and SocketTimeout.

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