⏱️ golxzn::os::chrono ⏱️ 1.2.4
Chrono for golxzn's projects.
Loading...
Searching...
No Matches
golxzn::os::chrono::fast_timer< BaseClock > Class Template Reference

Class that represents fast_timer. More...

#include <timer.hpp>

Public Types

using base_clock = BaseClock
 Base clock type.
 
using time_point = typename base_clock::time_point
 Type of time point from base_clock.
 

Public Member Functions

constexpr fast_timer (const time timer_interval) noexcept
 fast_timer constructor from timer interval.
 
constexpr fast_timer (const time_point timer_interval) noexcept
 fast_timer constructor from timer interval.
 
template<class Rep , class Period >
constexpr fast_timer (const std::chrono::duration< Rep, Period > timer_interval) noexcept
 fast_timer constructor from timer interval.
 
constexpr bool is_done () const noexcept
 Returns true if timer is done.
 
constexpr bool is_running () const noexcept
 Returns true if timer is running.
 
constexpr time time_left () const noexcept
 Returns time left to the end of the timer.
 

Detailed Description

template<class BaseClock = utils::default_base_clock>
class golxzn::os::chrono::fast_timer< BaseClock >

Class that represents fast_timer.

Compared to golxzn::os::chrono::timer it doesn't use a thread and callback.

Template Parameters
BaseClockclock that will be used for measurement. It has to be monotonic and STL compatible.

This class is used to measure time. It doesn't use a thread and callback. It stores only start time and timer interval, which is passing in constructor. So it's very lightweight. It's just check if the creating time + interval is less than current time.

Example of using:

while (timer.is_running()) {
const auto left{ timer.time_left() };
// do something
}
Class that represents fast_timer.
Definition timer.hpp:169
Class that represents timer.
Definition timer.hpp:60
time time_left() const noexcept
Returns time left to the end of the timer.
bool is_running() const noexcept
Returns true if timer is running.

Constructor & Destructor Documentation

◆ fast_timer() [1/3]

template<class BaseClock = utils::default_base_clock>
constexpr golxzn::os::chrono::fast_timer< BaseClock >::fast_timer ( const time  timer_interval)
explicitconstexprnoexcept

fast_timer constructor from timer interval.

Parameters
timer_intervalTimer interval.
See also
constexpr fast_timer(const time timer_interval) noexcept
constexpr fast_timer(const std::chrono::duration<Rep, Period> timer_interval) noexcept

◆ fast_timer() [2/3]

template<class BaseClock = utils::default_base_clock>
constexpr golxzn::os::chrono::fast_timer< BaseClock >::fast_timer ( const time_point  timer_interval)
explicitconstexprnoexcept

fast_timer constructor from timer interval.

Parameters
timer_intervalTimer interval.
See also
constexpr fast_timer(const time timer_interval) noexcept
constexpr fast_timer(const std::chrono::duration<Rep, Period> timer_interval) noexcept

◆ fast_timer() [3/3]

template<class BaseClock = utils::default_base_clock>
template<class Rep , class Period >
constexpr golxzn::os::chrono::fast_timer< BaseClock >::fast_timer ( const std::chrono::duration< Rep, Period >  timer_interval)
explicitconstexprnoexcept

fast_timer constructor from timer interval.

Parameters
timer_intervalTimer interval.
See also
constexpr fast_timer(const time timer_interval)
constexpr fast_timer(const time_point timer_interval)

Member Function Documentation

◆ is_done()

template<class BaseClock = utils::default_base_clock>
constexpr bool golxzn::os::chrono::fast_timer< BaseClock >::is_done ( ) const
constexprnoexcept

Returns true if timer is done.

See also
constexpr bool is_running() const noexcept
constexpr time time_left() const noexcept

◆ is_running()

template<class BaseClock = utils::default_base_clock>
constexpr bool golxzn::os::chrono::fast_timer< BaseClock >::is_running ( ) const
constexprnoexcept

Returns true if timer is running.

See also
constexpr bool is_done() const noexcept
constexpr time time_left() const noexcept

◆ time_left()

template<class BaseClock = utils::default_base_clock>
constexpr time golxzn::os::chrono::fast_timer< BaseClock >::time_left ( ) const
constexprnoexcept

Returns time left to the end of the timer.

See also
constexpr bool is_running() const noexcept
constexpr bool is_done() const noexcept

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