OS  v1.7.5
Documentation
Loading...
Searching...
No Matches
timer.hpp
1#ifndef QOS_CPP_TIMER
2#define QOS_CPP_TIMER
3
4#include "include/types.hpp"
5#include "include/clock.hpp"
6
7namespace qOS {
8
15
26 class timer {
27 private:
28 qOS::clock_t tStart{ 0U };
29 qOS::clock_t tv{ 0U };
30 public:
31 timer() noexcept;
33 virtual ~timer() {}
43 explicit timer( const qOS::duration_t tTime )
44 {
45 (void)set( tTime );
46 }
47
56 bool set( const qOS::duration_t tTime ) noexcept;
60 void disarm( void ) noexcept;
65 void reload( void ) noexcept;
70 bool status( void ) const noexcept;
88 bool reloadIfExpired( const qOS::duration_t tTime ) noexcept;
104 bool reloadIfExpired( void ) noexcept;
109 qOS::clock_t remaining( void ) const noexcept;
114 qOS::clock_t elapsed( void ) const noexcept;
120 bool expired( void ) const noexcept;
125 bool deadLineCheck( void ) const noexcept;
130 qOS::clock_t getInterval( void ) const noexcept;
146 timer& operator=( const bool en );
152 bool operator()( void ) const;
160 bool operator()( const qOS::duration_t tTime );
168 void operator()( const bool en );
174 explicit operator bool() const noexcept {
175 return expired();
176 }
177
178 static const bool ARMED;
180 static const bool DISARMED;
187 };
188
190}
191
192bool operator==( const qOS::timer& obj, bool value );
193
194#endif /*QOS_CPP_TIMER*/
195
A non-blocking Timer object.
Definition timer.hpp:26
bool operator()(const qOS::duration_t tTime)
Set the expiration time for a timer and gets armed immediately.
void reload(void) noexcept
Reload the timer with the previous specified time.
static const bool DISARMED
Constant that defines the status of a disarmed timer.
Definition timer.hpp:180
qOS::clock_t elapsed(void) const noexcept
Retrieve the elapsed time in epochs.
bool set(const qOS::duration_t tTime) noexcept
Set the expiration time for a timer. On success, the timer gets armed immediately.
timer() noexcept
timer(const qOS::duration_t tTime)
Initializes the instance of the timer with the specified expiration time. Timer will start armed.
Definition timer.hpp:43
timer & operator=(const qOS::duration_t tTime)
Set the expiration time for a timer and gets armed immediately.
bool deadLineCheck(void) const noexcept
Check if the specified deadline for has been reached.
void operator()(const bool en)
Disarm or reload the timer.
bool status(void) const noexcept
Get the current status of the Timer (Armed or Disarmed)
qOS::clock_t getInterval(void) const noexcept
Retrieve the timer interval value.
static const qOS::clock_t DISARM_VALUE
Constant that defines the value of a disarmed timer.
Definition timer.hpp:182
bool expired(void) const noexcept
Non-Blocking timer check.
bool operator()(void) const
Non-Blocking timer check.
void disarm(void) noexcept
Disarms the timer object.
static const qOS::clock_t REMAINING_IN_DISARMED_STATE
Constant that defines the value that a disarmed timer returns when the remaining time is requested.
Definition timer.hpp:186
static const bool ARMED
Constant that defines the status of an armed timer.
Definition timer.hpp:178
bool reloadIfExpired(const qOS::duration_t tTime) noexcept
Non-Blocking timer check with automatic arming.
bool reloadIfExpired(void) noexcept
Non-Blocking timer check with automatic arming.
timer & operator=(const bool en)
Disarm or reload the timer.
qOS::clock_t remaining(void) const noexcept
Retrieve the remaining time in epochs.
timeCount_t duration_t
The typedef that specified an time quantity, usually expressed in milliseconds.
Definition clock.hpp:18
timeCount_t clock_t
A unsigned integer to hold ticks count. Epochs counter.
Definition clock.hpp:15
OS/Kernel interfaces.
Definition bytebuffer.hpp:7