libzed 1.9.9
A general-purpose library for quick and simple data manipulation.
 
Loading...
Searching...
No Matches
z::core::timeout Class Reference

A class for easily managing timing. More...

#include <timeout.hpp>

Inheritance diagram for z::core::timeout:
z::core::timer

Public Member Functions

 timeout (unsigned int timeout_micros=-1, bool run=true) noexcept
 Timeout constructor.
 
void setTimeOut (unsigned int timeout_micros) noexcept
 Set the time out goal.
 
bool timedOut () const noexcept
 Check whether the timer has timed out.
 
template<class Archive >
void save (Archive &ar) const
 Serialization output.
 
template<class Archive >
void load (Archive &ar)
 Serialization input.
 
- Public Member Functions inherited from z::core::timer
 timer (bool run=true) noexcept
 Timer constructor.
 
void reset () noexcept
 Reset the timer.
 
void reset (std::chrono::high_resolution_clock::time_point time) noexcept
 reset the timer to a specific point in time.
 
unsigned int micros () const noexcept
 Get the elapsed time in microseconds.
 
unsigned int millis () const noexcept
 Get the elapsed time in milliseconds.
 
unsigned int seconds () const noexcept
 Get the elapsed time in seconds.
 
unsigned int minutes () const noexcept
 Get the elapsed time in minutes.
 
unsigned int hours () const noexcept
 Get the elapsed time in minutes.
 
template<class Archive >
void save (Archive &ar) const
 Serialization output.
 
template<class Archive >
void load (Archive &ar)
 Serialization input.
 

Detailed Description

A class for easily managing timing.

An extended version of the timer class which includes a timeout boundary.

Constructor & Destructor Documentation

◆ timeout()

z::core::timeout::timeout ( unsigned int  timeout_micros = -1,
bool  run = true 
)
noexcept

Timeout constructor.

Parameters
timeout_microsthe number of microseconds after which the timer will time out. If this is set to a negative value, then it will never time out.
runan optional parameter to decide whether the timer should start now.

Member Function Documentation

◆ load()

template<class Archive >
void z::core::timeout::load ( Archive ar)
inline

Serialization input.

Parameters
arThe input archive.

◆ save()

template<class Archive >
void z::core::timeout::save ( Archive ar) const
inline

Serialization output.

Parameters
arThe output archive.

◆ setTimeOut()

void z::core::timeout::setTimeOut ( unsigned int  timeout_micros)
noexcept

Set the time out goal.

Parameters
timeout_microsthe number of microseconds after which the timer will time out. If this is set to a negative value, then it will never time out.

◆ timedOut()

bool z::core::timeout::timedOut ( ) const
noexcept

Check whether the timer has timed out.

Returns
True if the timer has passed the specified time limit. False otherwise.

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