![]() |
SuperTinyKernel™ RTOS 1.05.3
Lightweight, high-performance, deterministic, bare-metal C++ RTOS for resource-constrained embedded systems. MIT Open Source License.
|
Abstract base class for a timer managed by TimerHost. More...
#include <stk_time_timer.h>
Public Member Functions | |
| Timer () | |
| ~Timer () | |
| Destructor. | |
| virtual void | OnExpired (TimerHost *host)=0 |
| bool | IsActive () const |
| Ticks | GetDeadline () const |
| Ticks | GetTimestamp () const |
| uint32_t | GetPeriod () const |
| uint32_t | GetRemainingTime () const |
| Get remaining ticks until the timer next expires. | |
Private Types | |
| typedef DListEntry< Timer, _ClosedLoop > | DLEntryType |
| Convenience alias for this entry type. Used to avoid repeating the full template spelling. | |
| typedef DListHead< Timer, _ClosedLoop > | DLHeadType |
| Convenience alias for the corresponding list head type. | |
Private Member Functions | |
| STK_NONCOPYABLE_CLASS (Timer) | |
| DLHeadType * | GetHead () const |
| Get the list head this entry currently belongs to. | |
| DLEntryType * | GetNext () const |
| Get the next entry in the list. | |
| DLEntryType * | GetPrev () const |
| Get the previous entry in the list. | |
| bool | IsLinked () const |
| Check whether this entry is currently a member of any list. | |
| operator Timer * () | |
| Implicit conversion to a mutable pointer to the host object (T). | |
| operator const Timer * () const | |
| Implicit conversion to a const pointer to the host object (T). | |
| void | Link (DLHeadType *head, DLEntryType *next, DLEntryType *prev) |
| Wire this entry into a list between prev and next. | |
| void | Unlink () |
| Remove this entry from its current list. | |
Private Attributes | |
| Ticks | m_deadline |
| absolute expiration time (ticks) | |
| Ticks | m_timestamp |
| time at which timer expired (ticks), updated by TimerHost | |
| uint32_t | m_period |
| reload period in ticks (0 = one-shot) | |
| volatile bool | m_active |
| true if active | |
| volatile bool | m_pending |
| true if pending to be handled | |
| DLHeadType * | m_head |
Owning list head, or NULL when the entry is not linked. | |
| DLEntryType * | m_next |
Next entry in the list, or NULL (open list boundary) / first entry (closed loop). | |
| DLEntryType * | m_prev |
Previous entry in the list, or NULL (open list boundary) / last entry (closed loop). | |
Friends | |
| class | TimerHost |
Abstract base class for a timer managed by TimerHost.
To implement a concrete timer, inherit from this class and override OnExpired(). The timer instance must outlive the TimerHost or be explicitly stopped before destruction, as TimerHost holds a non-owning pointer to each active timer.
Each Timer instance may be registered with at most one TimerHost at a time.
Definition at line 137 of file stk_time_timer.h.
|
inherited |
Convenience alias for this entry type. Used to avoid repeating the full template spelling.
Definition at line 70 of file stk_linked_list.h.
|
inherited |
Convenience alias for the corresponding list head type.
Definition at line 75 of file stk_linked_list.h.
|
inline |
Definition at line 142 of file stk_time_timer.h.
References m_active, m_deadline, m_pending, m_period, and m_timestamp.
Referenced by STK_NONCOPYABLE_CLASS().
|
inline |
Destructor.
Definition at line 148 of file stk_time_timer.h.
|
inline |
Definition at line 154 of file stk_time_timer.h.
References m_deadline.
Referenced by stk_timer_get_deadline().
|
inlineinherited |
Get the list head this entry currently belongs to.
NULL if the entry is not linked. Definition at line 80 of file stk_linked_list.h.
|
inlineinherited |
Get the next entry in the list.
NULL if this is the last entry (open list) or the first entry (closed loop, where next wraps to first). _ClosedLoop == true) this pointer is never NULL when the entry is linked. Definition at line 88 of file stk_linked_list.h.
|
inline |
Definition at line 156 of file stk_time_timer.h.
References m_period.
Referenced by stk_timer_get_period().
|
inlineinherited |
Get the previous entry in the list.
NULL if this is the first entry (open list) or the last entry (closed loop, where prev wraps to last). _ClosedLoop == true) this pointer is never NULL when the entry is linked. Definition at line 96 of file stk_linked_list.h.
|
inline |
Get remaining ticks until the timer next expires.
Definition at line 370 of file stk_time_timer.h.
References stk::GetTicks(), m_active, and m_deadline.
Referenced by stk_timer_get_remaining_time().
|
inline |
Definition at line 155 of file stk_time_timer.h.
References m_timestamp.
Referenced by stk_timer_get_timestamp().
|
inline |
Definition at line 153 of file stk_time_timer.h.
References m_active.
Referenced by stk::test::timer::MultipleTimersTask< _AccessMode >::Run(), stk_timer_destroy(), and stk_timer_is_active().
|
inlineinherited |
Check whether this entry is currently a member of any list.
true if linked (m_head != NULL); false otherwise. Definition at line 101 of file stk_linked_list.h.
|
inlineprivateinherited |
Wire this entry into a list between prev and next.
| [in] | head | The owning DListHead. Stored as a back-pointer for IsLinked() and ownership checks. |
| [in] | next | The entry that will follow this one, or NULL if this becomes the last entry. |
| [in] | prev | The entry that will precede this one, or NULL if this becomes the first entry. |
Definition at line 137 of file stk_linked_list.h.
|
pure virtual |
Implemented in CTimerWrapper, and stk::test::timer::TestTimer.
References TimerHost.
Referenced by stk::time::TimerHost::ProcessTimers().
|
inlineinherited |
Implicit conversion to a const pointer to the host object (T).
Definition at line 115 of file stk_linked_list.h.
|
inlineinherited |
Implicit conversion to a mutable pointer to the host object (T).
Definition at line 108 of file stk_linked_list.h.
|
private |
|
inlineprivateinherited |
Remove this entry from its current list.
Definition at line 157 of file stk_linked_list.h.
|
friend |
Definition at line 139 of file stk_time_timer.h.
References TimerHost.
Referenced by CTimerWrapper::OnExpired(), OnExpired(), and TimerHost.
|
private |
true if active
Definition at line 172 of file stk_time_timer.h.
Referenced by GetRemainingTime(), IsActive(), stk::time::TimerHost::ProcessCommands(), stk::time::TimerHost::Reset(), stk::time::TimerHost::SetPeriod(), stk::time::TimerHost::Start(), stk::time::TimerHost::Stop(), Timer(), and stk::time::TimerHost::UpdateTime().
|
private |
absolute expiration time (ticks)
Definition at line 169 of file stk_time_timer.h.
Referenced by GetDeadline(), GetRemainingTime(), stk::time::TimerHost::ProcessCommands(), Timer(), and stk::time::TimerHost::UpdateTime().
|
privateinherited |
Owning list head, or NULL when the entry is not linked.
Definition at line 170 of file stk_linked_list.h.
|
privateinherited |
Next entry in the list, or NULL (open list boundary) / first entry (closed loop).
Definition at line 171 of file stk_linked_list.h.
|
private |
true if pending to be handled
Definition at line 173 of file stk_time_timer.h.
Referenced by stk::time::TimerHost::ProcessCommands(), stk::time::TimerHost::ProcessTimers(), Timer(), and stk::time::TimerHost::UpdateTime().
|
private |
reload period in ticks (0 = one-shot)
Definition at line 171 of file stk_time_timer.h.
Referenced by GetPeriod(), stk::time::TimerHost::ProcessCommands(), stk::time::TimerHost::Reset(), stk::time::TimerHost::SetPeriod(), Timer(), and stk::time::TimerHost::UpdateTime().
|
privateinherited |
Previous entry in the list, or NULL (open list boundary) / last entry (closed loop).
Definition at line 172 of file stk_linked_list.h.
|
private |
time at which timer expired (ticks), updated by TimerHost
Definition at line 170 of file stk_time_timer.h.
Referenced by GetTimestamp(), Timer(), and stk::time::TimerHost::UpdateTime().