|
| | TimerHandle () noexcept |
| | Default constructor which creates an invalid object. More...
|
| |
| | ~TimerHandle () noexcept |
| | Destroying the TimerHandle also deletes it from the TimerManager's timer allocation queue. More...
|
| |
| | TimerHandle (TimerHandle &&rhs) noexcept |
| | Move Constructor. More...
|
| |
| TimerHandle & | operator= (TimerHandle &&rhs) noexcept |
| | Move assignment operator. More...
|
| |
| | TimerHandle (const TimerHandle &)=delete |
| | Delete the copy constructor. More...
|
| |
| const TimerHandle & | operator= (const TimerHandle &)=delete |
| | Delete the copy assignment operator. More...
|
| |
| bool | valid () const noexcept |
| | Check if the TimerHandle is valid. More...
|
| |
| | operator bool () const noexcept |
| | Operator bool checks validity. More...
|
| |
| void | destroy () noexcept |
| | Destroy the TimerHandle. More...
|
| |
| bool | cancel () noexcept |
| | Cancel a software timer. More...
|
| |
| template<typename TRep , typename TPeriod > |
| void | asyncDelay (const std::chrono::duration< TRep, TPeriod > &delay, const TTimeoutCallback &func) noexcept |
| | Configure a one-shot delay. More...
|
| |
| template<typename TRep , typename TPeriod > |
| void | asyncDelay (const std::chrono::duration< TRep, TPeriod > &delay, TTimeoutCallback &&func) noexcept |
| | Configure a one-shot delay. More...
|
| |
| template<typename TRep , typename TPeriod > |
| void | periodicDelay (const std::chrono::duration< TRep, TPeriod > &delay, const TTimeoutCallback &func) noexcept |
| | Configure a periodic delay. More...
|
| |
| template<typename TRep , typename TPeriod > |
| void | periodicDelay (const std::chrono::duration< TRep, TPeriod > &delay, TTimeoutCallback &&func) noexcept |
| | Configure a periodic delay. More...
|
| |
template<const size_t TMaxTimers = 0, typename TLock = embutil::nop_lock, typename TTimeUnit = embvm::timer::timer_period_t, typename TTimeoutCallback = stdext::inplace_function<void()>, typename TTimerDevice = embvm::timer::Timer>
class embvm::TimerManager< TMaxTimers, TLock, TTimeUnit, TTimeoutCallback, TTimerDevice >::TimerHandle
Handle to a software timer.
TimerHandle represents a handle to an event registration. TimerHandle are created during the TimerManager::allocate() process.
The handle is used to schedule delays:
h.asyncDelay(std::chrono::milliseconds(1), cb_called);
The lifetime of the TimerHandle controls the lifetime of the software timer. If the handle leaves scope, the timer will be automatically unregistered.
Template parameters simply match those in the original TimerManager declaration, since TimerHandle is a class member.
template<const size_t TMaxTimers = 0, typename TLock = embutil::nop_lock, typename TTimeUnit = embvm::timer::timer_period_t, typename TTimeoutCallback = stdext::inplace_function<void()>, typename TTimerDevice = embvm::timer::Timer>
template<typename TRep , typename TPeriod >
| void embvm::TimerManager< TMaxTimers, TLock, TTimeUnit, TTimeoutCallback, TTimerDevice >::TimerHandle::asyncDelay |
( |
const std::chrono::duration< TRep, TPeriod > & |
delay, |
|
|
const TTimeoutCallback & |
func |
|
) |
| |
|
inlinenoexcept |
Configure a one-shot delay.
Configure the software timer to perform a one-shot asynchronous delay. When the timer expires, the callback will be called. The timer will be removed from the scheduled queue.
- Precondition
- The TimerHandle is valid.
- Postcondition
- The periodic delay is scheduled.
The following template parameters should be automatically deduced by the compiler:
- Template Parameters
-
| TRep | Underlying storage type (representation) for the time units (e.g., uint32_t, uint64_t) |
| TPeriod | A std::ratio representing the tick period (e.g., std::nano) |
- Parameters
-
| [in] | delay | std::chrono::duration representing the periodic timeout value delta. For example: std::chrono::duration<uint64_t, std::nano> delay = std::chrono::nanoseconds(1000); |
| [in] | func | Function object that will be registered as the software timer callback. |
References assert, and embvm::timer::oneshot.
template<const size_t TMaxTimers = 0, typename TLock = embutil::nop_lock, typename TTimeUnit = embvm::timer::timer_period_t, typename TTimeoutCallback = stdext::inplace_function<void()>, typename TTimerDevice = embvm::timer::Timer>
template<typename TRep , typename TPeriod >
| void embvm::TimerManager< TMaxTimers, TLock, TTimeUnit, TTimeoutCallback, TTimerDevice >::TimerHandle::asyncDelay |
( |
const std::chrono::duration< TRep, TPeriod > & |
delay, |
|
|
TTimeoutCallback && |
func |
|
) |
| |
|
inlinenoexcept |
Configure a one-shot delay.
Configure the software timer to perform a one-shot asynchronous delay. When the timer expires, the callback will be called. The timer will be removed from the scheduled queue.
- Precondition
- The TimerHandle is valid.
- Postcondition
- The periodic delay is scheduled.
The following template parameters should be automatically deduced by the compiler:
- Template Parameters
-
| TRep | Underlying storage type (representation) for the time units (e.g., uint32_t, uint64_t) |
| TPeriod | A std::ratio representing the tick period (e.g., std::nano) |
- Parameters
-
| [in] | delay | std::chrono::duration representing the periodic timeout value delta. For example: std::chrono::duration<uint64_t, std::nano> delay = std::chrono::nanoseconds(1000); |
| [in] | func | R-value function object that will be registered as the software timer callback. |
References assert, and embvm::timer::oneshot.
template<const size_t TMaxTimers = 0, typename TLock = embutil::nop_lock, typename TTimeUnit = embvm::timer::timer_period_t, typename TTimeoutCallback = stdext::inplace_function<void()>, typename TTimerDevice = embvm::timer::Timer>
Cancel a software timer.
Request cancellation for a software timer. The cancellation request is best-effort, and the timer may expire before the request is completed.
- Precondition
- The TimerHandle is valid
- Postcondition
- The timer is cancelled, or has expired before cancellation was carried out.
- Returns
- True if the timer was cancelled, false if the timer expired before cancellation.
References assert.
template<const size_t TMaxTimers = 0, typename TLock = embutil::nop_lock, typename TTimeUnit = embvm::timer::timer_period_t, typename TTimeoutCallback = stdext::inplace_function<void()>, typename TTimerDevice = embvm::timer::Timer>
| void embvm::TimerManager< TMaxTimers, TLock, TTimeUnit, TTimeoutCallback, TTimerDevice >::TimerHandle::destroy |
( |
| ) |
|
|
inlinenoexcept |
template<const size_t TMaxTimers = 0, typename TLock = embutil::nop_lock, typename TTimeUnit = embvm::timer::timer_period_t, typename TTimeoutCallback = stdext::inplace_function<void()>, typename TTimerDevice = embvm::timer::Timer>
| embvm::TimerManager< TMaxTimers, TLock, TTimeUnit, TTimeoutCallback, TTimerDevice >::TimerHandle::operator bool |
( |
| ) |
const |
|
inlinenoexcept |
Operator bool checks validity.
Operator bool() is used to check that a TimerHandle is valid.
- Returns
- true if the TimerHandle is valid, false otherwise
template<const size_t TMaxTimers = 0, typename TLock = embutil::nop_lock, typename TTimeUnit = embvm::timer::timer_period_t, typename TTimeoutCallback = stdext::inplace_function<void()>, typename TTimerDevice = embvm::timer::Timer>
template<typename TRep , typename TPeriod >
| void embvm::TimerManager< TMaxTimers, TLock, TTimeUnit, TTimeoutCallback, TTimerDevice >::TimerHandle::periodicDelay |
( |
const std::chrono::duration< TRep, TPeriod > & |
delay, |
|
|
const TTimeoutCallback & |
func |
|
) |
| |
|
inlinenoexcept |
Configure a periodic delay.
Configure the software timer to perform a periodic delay. When the timer expires, the callback will be called adn the timer will be automatically re-added to the scheduled timer queue.
- Precondition
- The TimerHandle is valid.
- Postcondition
- The periodic delay is scheduled.
The following template parameters should be automatically deduced by the compiler:
- Template Parameters
-
| TRep | Underlying storage type (representation) for the time units (e.g., uint32_t, uint64_t) |
| TPeriod | A std::ratio representing the tick period (e.g., std::nano) |
- Parameters
-
| [in] | delay | std::chrono::duration representing the periodic timeout value delta. For example: std::chrono::duration<uint64_t, std::nano> delay = std::chrono::nanoseconds(1000); |
| [in] | func | Function object that will be registered as the software timer callback. |
References assert, and embvm::timer::periodic.
template<const size_t TMaxTimers = 0, typename TLock = embutil::nop_lock, typename TTimeUnit = embvm::timer::timer_period_t, typename TTimeoutCallback = stdext::inplace_function<void()>, typename TTimerDevice = embvm::timer::Timer>
template<typename TRep , typename TPeriod >
| void embvm::TimerManager< TMaxTimers, TLock, TTimeUnit, TTimeoutCallback, TTimerDevice >::TimerHandle::periodicDelay |
( |
const std::chrono::duration< TRep, TPeriod > & |
delay, |
|
|
TTimeoutCallback && |
func |
|
) |
| |
|
inlinenoexcept |
Configure a periodic delay.
Configure the software timer to perform a periodic delay. When the timer expires, the callback will be called adn the timer will be automatically re-added to the scheduled timer queue.
- Precondition
- The TimerHandle is valid.
- Postcondition
- The periodic delay is scheduled.
The following template parameters should be automatically deduced by the compiler:
- Template Parameters
-
| TRep | Underlying storage type (representation) for the time units (e.g., uint32_t, uint64_t) |
| TPeriod | A std::ratio representing the tick period (e.g., std::nano) |
- Parameters
-
| [in] | delay | std::chrono::duration representing the periodic timeout value delta. For example: std::chrono::duration<uint64_t, std::nano> delay = std::chrono::nanoseconds(1000); |
| [in] | func | R-value function object that will be registered as the software timer callback. |
References assert, and embvm::timer::periodic.