Mana
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
Timer Class Reference

Simple timer that can be used to check if a certain amount of time has passed. More...

#include <time.h>

Public Member Functions

 Timer ()=default
 
void set (uint32_t ms=0)
 Sets the timer with an optional duration in milliseconds.
 
void reset ()
 Reset the timer.
 
bool isSet () const
 Returns whether the timer has been set.
 
bool passed () const
 Returns whether the timer has passed.
 
void extend (uint32_t ms)
 Extend the timer by the given number of milliseconds.
 
int32_t elapsed () const
 Returns the number of milliseconds elapsed since the set time, or a negative value if the timer hasn't passed.
 

Private Attributes

uint32_t mTimeout = 0
 

Detailed Description

Simple timer that can be used to check if a certain amount of time has passed.

Definition at line 61 of file time.h.

Constructor & Destructor Documentation

◆ Timer()

Timer::Timer ( )
default

Member Function Documentation

◆ elapsed()

int32_t Timer::elapsed ( ) const

Returns the number of milliseconds elapsed since the set time, or a negative value if the timer hasn't passed.

Due to wrapping, this function is not suitable for measuring long periods of time (tens of days).

Definition at line 65 of file time.cpp.

◆ extend()

void Timer::extend ( uint32_t  ms)
inline

Extend the timer by the given number of milliseconds.

Definition at line 94 of file time.h.

◆ isSet()

bool Timer::isSet ( ) const
inline

Returns whether the timer has been set.

Definition at line 81 of file time.h.

◆ passed()

bool Timer::passed ( ) const
inline

Returns whether the timer has passed.

A timer that wasn't set will always return true.

Definition at line 88 of file time.h.

◆ reset()

void Timer::reset ( )
inline

Reset the timer.

Definition at line 75 of file time.h.

◆ set()

void Timer::set ( uint32_t  ms = 0)
inline

Sets the timer with an optional duration in milliseconds.

Definition at line 69 of file time.h.

Member Data Documentation

◆ mTimeout

uint32_t Timer::mTimeout = 0
private

Definition at line 107 of file time.h.


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