SuperTinyKernel™ RTOS 1.06.x
Lightweight, high-performance, deterministic, bare-metal C++ RTOS for resource-constrained embedded systems. MIT Open Source License.
Loading...
Searching...
No Matches
stk::IWaitObject Class Referenceabstract

Wait object. More...

#include <stk_common.h>

Inheritance diagram for stk::IWaitObject:
Collaboration diagram for stk::IWaitObject:

Public Types

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

virtual TId GetTid () const =0
 Get thread Id of this task.
virtual void Wake (bool timeout)=0
 Wake task.
virtual bool IsTimeout () const =0
 Check if task woke up due to a timeout.
virtual bool Tick (Timeout elapsed_ticks)=0
 Update wait object's waiting time.
DLHeadTypeGetHead ()
 Get the list head this entry currently belongs to.
DLEntryTypeGetNext ()
 Get the next entry in the list.
DLEntryTypeGetPrev ()
 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).

Protected Member Functions

 ~IWaitObject ()=default
 Destructor.

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

DLHeadTypem_head
 Owning list head, or NULL when the entry is not linked.
DLEntryTypem_next
 Next entry in the list, or NULL (open list boundary) / first entry (closed loop).
DLEntryTypem_prev
 Previous entry in the list, or NULL (open list boundary) / last entry (closed loop).

Detailed Description

Wait object.

Definition at line 344 of file stk_common.h.

Member Typedef Documentation

◆ DLEntryType

typedef DListEntry<IWaitObject, TClosedLoop> stk::util::DListEntry< IWaitObject, TClosedLoop >::DLEntryType
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.

◆ DLHeadType

typedef DListHead<IWaitObject, TClosedLoop> stk::util::DListEntry< IWaitObject, TClosedLoop >::DLHeadType
inherited

Convenience alias for the corresponding list head type.

Definition at line 80 of file stk_linked_list.h.

◆ ListEntryType

List entry type of IWaitObject elements.

Definition at line 355 of file stk_common.h.

◆ ListHeadType

List head type for IWaitObject elements.

Definition at line 350 of file stk_common.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
inherited

A tag for type-safe casts done by CastListEntryToParent.

See also
CastListEntryToParent.

Definition at line 70 of file stk_linked_list.h.

70{ DLEntryTag = 1 };
Intrusive doubly-linked list node. Embed this as a base class in any object (T) that needs to partici...

Constructor & Destructor Documentation

◆ ~IWaitObject()

stk::IWaitObject::~IWaitObject ( )
protecteddefault

Destructor.

Member Function Documentation

◆ GetHead()

DLHeadType * stk::util::DListEntry< IWaitObject, TClosedLoop >::GetHead ( )
inlineinherited

Get the list head this entry currently belongs to.

Returns
Pointer to the owning DListHead, or NULL if the entry is not linked.

Definition at line 85 of file stk_linked_list.h.

85{ return m_head; }

◆ GetNext()

DLEntryType * stk::util::DListEntry< IWaitObject, TClosedLoop >::GetNext ( )
inlineinherited

Get the next entry in the list.

Returns
Pointer to the next DListEntry, or NULL if this is the last entry (open list) or the first entry (closed loop, where next wraps to first).
Note
In a closed loop (TClosedLoop == true) this pointer is never NULL when the entry is linked.

Definition at line 98 of file stk_linked_list.h.

98{ return m_next; }

◆ GetPrev()

DLEntryType * stk::util::DListEntry< IWaitObject, TClosedLoop >::GetPrev ( )
inlineinherited

Get the previous entry in the list.

Returns
Pointer to the previous DListEntry, or NULL if this is the first entry (open list) or the last entry (closed loop, where prev wraps to last).
Note
In a closed loop (TClosedLoop == true) this pointer is never NULL when the entry is linked.

Definition at line 114 of file stk_linked_list.h.

114{ return m_prev; }

◆ GetTid()

virtual TId stk::IWaitObject::GetTid ( ) const
pure virtual

Get thread Id of this task.

Returns
Thread Id.

Implemented in stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelTask::WaitObject.

Referenced by stk::ISyncObject::FindWeightHigherThan(), and stk::sync::Mutex::Unlock().

Here is the caller graph for this function:

◆ IsLinked()

bool stk::util::DListEntry< IWaitObject, TClosedLoop >::IsLinked ( ) const
inlineinherited

Check whether this entry is currently a member of any list.

Returns
true if linked (m_head != NULL); false otherwise.

Definition at line 127 of file stk_linked_list.h.

127{ return (GetHead() != nullptr); }

◆ IsTimeout()

virtual bool stk::IWaitObject::IsTimeout ( ) const
pure virtual

Check if task woke up due to a timeout.

Returns
Returns true if timeout, false otherwise.

Implemented in stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelTask::WaitObject.

Referenced by stk::sync::Event::RemoveWaitObject(), stk::sync::Mutex::TimedLock(), stk::sync::ConditionVariable::Wait(), stk::sync::Event::Wait(), and stk::sync::Semaphore::Wait().

Here is the caller graph for this function:

◆ Link()

void stk::util::DListEntry< IWaitObject, TClosedLoop >::Link ( DLHeadType * head,
DLEntryType * next,
DLEntryType * prev )
inlineprivateinherited

Wire this entry into a list between prev and next.

Parameters
[in]headThe owning DListHead. Stored as a back-pointer for IsLinked() and ownership checks.
[in]nextThe entry that will follow this one, or NULL if this becomes the last entry.
[in]prevThe entry that will precede this one, or NULL if this becomes the first entry.
Note
Called exclusively by DListHead::Link(). Assumes the entry is not currently linked. Updates the neighbours' forward/back pointers to splice this entry in.

Definition at line 162 of file stk_linked_list.h.

163 {
164 m_head = head;
165 m_next = next;
166 m_prev = prev;
167
168 if (m_prev != nullptr)
169 {
170 m_prev->m_next = this;
171 }
172
173 if (m_next != nullptr)
174 {
175 m_next->m_prev = this;
176 }
177 }
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).

◆ operator const IWaitObject *()

stk::util::DListEntry< IWaitObject, TClosedLoop >::operator const IWaitObject * ( ) const
inlineinherited

Implicit conversion to a const pointer to the host object (T).

Note
Safe because T must derive from DListEntry<T, TClosedLoop>. Eliminates the need for explicit static_cast at call sites.
MISRA deviation: [STK-DEV-004] Rule 5-2-x.

Definition at line 141 of file stk_linked_list.h.

141{ return static_cast<const T *>(this); }

◆ operator IWaitObject *()

stk::util::DListEntry< IWaitObject, TClosedLoop >::operator IWaitObject* ( )
inlineinherited

Implicit conversion to a mutable pointer to the host object (T).

Note
Safe because T must derive from DListEntry<T, TClosedLoop>. Eliminates the need for explicit static_cast at call sites.
MISRA deviation: [STK-DEV-004] Rule 5-2-x.

Definition at line 134 of file stk_linked_list.h.

134{ return static_cast<T *>(this); }

◆ Tick()

virtual bool stk::IWaitObject::Tick ( Timeout elapsed_ticks)
pure virtual

Update wait object's waiting time.

Parameters
[in]elapsed_ticksNumber of ticks elapsed between this and previous calls, in case of KERNEL_TICKLESS mode this value can be >1, for non-tickless mode it is always 1.
Returns
Returns true if update caused a timeout of the object, false otherwise.

Implemented in stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelTask::WaitObject.

Referenced by stk::ISyncObject::Tick().

Here is the caller graph for this function:

◆ Unlink()

void stk::util::DListEntry< IWaitObject, TClosedLoop >::Unlink ( )
inlineprivateinherited

Remove this entry from its current list.

Note
Called exclusively by DListHead::Unlink(). Patches the neighbours' pointers to bridge over this entry, then clears m_head, m_next, and m_prev to NULL so the entry is in a clean unlinked state.
Does not update DListHead::m_count or m_first / m_last — those are the responsibility of the calling DListHead::Unlink().

Definition at line 186 of file stk_linked_list.h.

187 {
188 if (m_prev != nullptr)
189 {
191 }
192
193 if (m_next != nullptr)
194 {
196 }
197
198 m_head = nullptr;
199 m_next = nullptr;
200 m_prev = nullptr;
201 }

◆ Wake()

virtual void stk::IWaitObject::Wake ( bool timeout)
pure virtual

Wake task.

Parameters
[in]timeouttrue if the task is waking due to timeout expiry; false if waking due to a successful signal.
Note
The implementation is responsible for removing this wait object from the synchronization object's wait list (via ISyncObject::RemoveWaitObject) as part of the wake sequence.

Implemented in stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelTask::WaitObject.

Referenced by stk::ISyncObject::Tick(), and stk::sync::Mutex::Unlock().

Here is the caller graph for this function:

Member Data Documentation

◆ m_head

DLHeadType* stk::util::DListEntry< IWaitObject, TClosedLoop >::m_head
privateinherited

Owning list head, or NULL when the entry is not linked.

Definition at line 203 of file stk_linked_list.h.

◆ m_next

DLEntryType* stk::util::DListEntry< IWaitObject, TClosedLoop >::m_next
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.

◆ m_prev

DLEntryType* stk::util::DListEntry< IWaitObject, TClosedLoop >::m_prev
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.


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