|
SuperTinyKernel™ RTOS 1.08.x
Lightweight, high-performance, deterministic, bare-metal C++ RTOS for resource-constrained embedded systems. MIT Open Source License.
|
Concrete implementation of IWaitObject, embedded in each KernelTask slot. More...
#include <stk.h>
Classes | |
| class | WaitRequest |
| Payload stored in the sync object's kernel-side list entry while a task is waiting. More... | |
Public Types | |
| enum | EState : uint8_t { STATE_NONE = 0U , STATE_WAIT , STATE_SIGNALED , STATE_TIMEOUT , STATE_CANCELLED } |
| State of the WaitObject. More... | |
| typedef DLHeadType | ListHeadType |
| List head type for IWaitObject elements. | |
| typedef DLEntryType | ListEntryType |
| List entry type of IWaitObject elements. | |
| enum | |
| A tag for type-safe casts done by CastListEntryToParent. More... | |
| typedef DListEntry< IWaitObject, TClosedLoop > | DLEntryType |
| Convenience alias for this entry type. Used to avoid repeating the full template spelling. | |
| typedef DListHead< IWaitObject, TClosedLoop > | DLHeadType |
| Convenience alias for the corresponding list head type. | |
Public Member Functions | |
| WaitObject () | |
| ~WaitObject ()=default | |
| Destructor. | |
| TId | GetTid () const override |
| Get the TId of the task that owns this wait object. | |
| EState | GetState () const override |
| Get current state. | |
| bool | IsWaiting () const |
| Check if busy with waiting. | |
| EWaitResult | GetWaitResult () const |
| Get wait result. | |
| void | ClearState () |
| Clear state. | |
| void | Wake (bool timeout) override |
| Wake the waiting task (called by ISyncObject when it signals). | |
| bool | Tick (Timeout elapsed_ticks) override |
| Advance the timeout countdown by a number of ticks. | |
| void | SetupWait (ISyncObject *sync_obj, Timeout timeout) |
| Configure and arm this wait object for a new wait operation. | |
| void | CancelNoWake () |
| Cancel an in-progress wait without waking the owning task. | |
| void | Cancel () |
| Cancel an in-progress wait and wake the owning task early. | |
| bool | CancelIfWaiting () |
| Cancel an in-progress wait and wake the owning task early if was waiting. | |
| DLHeadType * | GetHead () |
| Get the list head this entry currently belongs to. | |
| DLEntryType * | GetNext () |
| Get the next entry in the list. | |
| DLEntryType * | GetPrev () |
| Get the previous entry in the list. | |
| bool | IsLinked () const |
| Check whether this entry is currently a member of any list. | |
| operator IWaitObject * () | |
| Implicit conversion to a mutable pointer to the host object (T). | |
| operator const IWaitObject * () const | |
| Implicit conversion to a const pointer to the host object (T). | |
Public Attributes | |
| KernelTask * | m_task |
| Back-pointer to the owning KernelTask. Set once at construction; never changes. | |
| ISyncObject * | m_sync_obj |
Sync object this wait is registered with, or NULL when not waiting. | |
| Timeout | m_time_wait |
| Ticks remaining until timeout. Decremented each tick; WAIT_INFINITE means no timeout. | |
| volatile EState | m_state |
| State of the object, see WaitObject::EState. | |
Private Member Functions | |
| 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 | |
| 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). | |
Concrete implementation of IWaitObject, embedded in each KernelTask slot.
|
inherited |
Convenience alias for this entry type. Used to avoid repeating the full template spelling.
Definition at line 75 of file stk_linked_list.h.
|
inherited |
Convenience alias for the corresponding list head type.
Definition at line 80 of file stk_linked_list.h.
|
inherited |
List entry type of IWaitObject elements.
Definition at line 507 of file stk_common.h.
|
inherited |
List head type for IWaitObject elements.
Definition at line 502 of file stk_common.h.
|
inherited |
A tag for type-safe casts done by CastListEntryToParent.
Definition at line 70 of file stk_linked_list.h.
|
inherited |
State of the WaitObject.
| Enumerator | |
|---|---|
| STATE_NONE | |
| STATE_WAIT | Wait is active. |
| STATE_SIGNALED | Wake signaled. |
| STATE_TIMEOUT | Wait expired due to timeout rather than a Wake() signal. |
| STATE_CANCELLED | Wait was cancelled via Cancel() rather than Wake()/timeout. |
Definition at line 512 of file stk_common.h.
|
inlineexplicit |
Definition at line 526 of file stk.h.
References m_state, m_sync_obj, m_task, m_time_wait, stk::NO_WAIT, and stk::IWaitObject::STATE_NONE.
|
default |
|
inline |
Cancel an in-progress wait and wake the owning task early.
Definition at line 682 of file stk.h.
References IsWaiting(), m_state, m_sync_obj, m_task, m_time_wait, stk::NO_WAIT, stk::IWaitObject::STATE_CANCELLED, and STK_ASSERT.
Referenced by CancelIfWaiting().
|
inline |
Cancel an in-progress wait and wake the owning task early if was waiting.
Definition at line 699 of file stk.h.
References Cancel(), and IsWaiting().
|
inline |
Cancel an in-progress wait without waking the owning task.
Definition at line 660 of file stk.h.
References IsWaiting(), m_state, m_sync_obj, and stk::IWaitObject::STATE_CANCELLED.
|
inline |
Clear state.
Definition at line 586 of file stk.h.
References IsWaiting(), m_state, stk::IWaitObject::STATE_NONE, and STK_ASSERT.
|
inlineinherited |
Get the list head this entry currently belongs to.
NULL if the entry is not linked. Definition at line 85 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). TClosedLoop == true) this pointer is never NULL when the entry is linked. Definition at line 98 of file stk_linked_list.h.
|
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). TClosedLoop == true) this pointer is never NULL when the entry is linked. Definition at line 114 of file stk_linked_list.h.
|
inlineoverridevirtual |
Get current state.
Implements stk::IWaitObject.
Definition at line 554 of file stk.h.
References m_state.
Referenced by GetWaitResult().
|
inlineoverridevirtual |
|
inline |
Get wait result.
Definition at line 565 of file stk.h.
References GetState(), IsWaiting(), m_state, stk::IWaitObject::STATE_CANCELLED, stk::IWaitObject::STATE_NONE, stk::IWaitObject::STATE_SIGNALED, stk::IWaitObject::STATE_TIMEOUT, stk::IWaitObject::STATE_WAIT, STK_ASSERT, stk::WAIT_RESULT_CANCELED, stk::WAIT_RESULT_SIGNAL, and stk::WAIT_RESULT_TIMEOUT.
|
inlineinherited |
Check whether this entry is currently a member of any list.
true if linked (m_head != NULL); false otherwise. Definition at line 127 of file stk_linked_list.h.
|
inline |
Check if busy with waiting.
true if waiting, false if not. Definition at line 559 of file stk.h.
References m_sync_obj.
Referenced by Cancel(), CancelIfWaiting(), CancelNoWake(), ClearState(), stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelTask::GetSleepTicks(), GetWaitResult(), SetupWait(), and Wake().
|
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 162 of file stk_linked_list.h.
|
inlineinherited |
Implicit conversion to a const pointer to the host object (T).
Definition at line 141 of file stk_linked_list.h.
|
inlineinherited |
Implicit conversion to a mutable pointer to the host object (T).
Definition at line 134 of file stk_linked_list.h.
|
inline |
Configure and arm this wait object for a new wait operation.
| [in] | sync_obj | The synchronization object to wait on. Must not already have this wait object registered (asserted). |
| [in] | timeout | Maximum ticks to wait, or WAIT_INFINITE for no timeout. |
Definition at line 642 of file stk.h.
References stk::ISyncObject::AddWaitObject(), IsWaiting(), m_state, m_sync_obj, m_time_wait, stk::IWaitObject::STATE_WAIT, and STK_ASSERT.
|
inlineoverridevirtual |
Advance the timeout countdown by a number of ticks.
true if the wait is still active (not yet timed out), false if the timeout just expired (caller should stop ticking this object). true. Implements stk::IWaitObject.
Definition at line 617 of file stk.h.
References m_state, m_time_wait, stk::NO_WAIT, stk::IWaitObject::STATE_TIMEOUT, stk::IWaitObject::STATE_WAIT, and stk::WAIT_INFINITE.
|
inlineprivateinherited |
Remove this entry from its current list.
Definition at line 186 of file stk_linked_list.h.
|
inlineoverridevirtual |
Wake the waiting task (called by ISyncObject when it signals).
| [in] | timeout | true if woken because the timeout expired, false if signalled. |
Implements stk::IWaitObject.
Definition at line 598 of file stk.h.
References IsWaiting(), m_state, m_sync_obj, m_task, m_time_wait, stk::NO_WAIT, stk::IWaitObject::STATE_SIGNALED, stk::IWaitObject::STATE_TIMEOUT, and STK_ASSERT.
|
privateinherited |
Owning list head, or NULL when the entry is not linked.
Definition at line 203 of file stk_linked_list.h.
|
privateinherited |
Next entry in the list, or NULL (open list boundary) / first entry (closed loop).
Definition at line 204 of file stk_linked_list.h.
|
privateinherited |
Previous entry in the list, or NULL (open list boundary) / last entry (closed loop).
Definition at line 205 of file stk_linked_list.h.
| volatile EState stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelTask::WaitObject::m_state |
State of the object, see WaitObject::EState.
Definition at line 713 of file stk.h.
Referenced by Cancel(), CancelNoWake(), ClearState(), GetState(), GetWaitResult(), SetupWait(), Tick(), WaitObject(), and Wake().
| ISyncObject* stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelTask::WaitObject::m_sync_obj |
Sync object this wait is registered with, or NULL when not waiting.
Definition at line 711 of file stk.h.
Referenced by Cancel(), CancelNoWake(), IsWaiting(), SetupWait(), WaitObject(), and Wake().
| KernelTask* stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelTask::WaitObject::m_task |
Back-pointer to the owning KernelTask. Set once at construction; never changes.
Definition at line 710 of file stk.h.
Referenced by Cancel(), GetTid(), WaitObject(), and Wake().
| Timeout stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelTask::WaitObject::m_time_wait |
Ticks remaining until timeout. Decremented each tick; WAIT_INFINITE means no timeout.
Definition at line 712 of file stk.h.
Referenced by Cancel(), stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelTask::GetSleepTicks(), SetupWait(), Tick(), WaitObject(), and Wake().