SuperTinyKernel™ RTOS 1.05.3
Lightweight, high-performance, deterministic, bare-metal C++ RTOS for resource-constrained embedded systems. MIT Open Source License.
Loading...
Searching...
No Matches
stk::test::SyncObjectMock Struct Reference

#include <stktest.h>

Inheritance diagram for stk::test::SyncObjectMock:
Collaboration diagram for stk::test::SyncObjectMock:

Public Types

typedef DLHeadType ListHeadType
 List head type for ISyncObject elements.
typedef DLEntryType ListEntryType
 List entry type of ISyncObject elements.
typedef DListEntry< ISyncObject, _ClosedLoop > DLEntryType
 Convenience alias for this entry type. Used to avoid repeating the full template spelling.
typedef DListHead< ISyncObject, _ClosedLoop > DLHeadType
 Convenience alias for the corresponding list head type.

Public Member Functions

void WakeOne ()
void WakeAll ()
virtual void AddWaitObject (IWaitObject *wobj)
 Called by kernel when a new task starts waiting on this event.
virtual void RemoveWaitObject (IWaitObject *wobj)
 Called by kernel when a waiting task is being removed (timeout expired, wait aborted, task terminated etc.).
virtual bool Tick (Timeout elapsed_ticks)
 Called by kernel on every system tick to handle timeout logic of waiting tasks.
DLHeadTypeGetHead () const
 Get the list head this entry currently belongs to.
DLEntryTypeGetNext () const
 Get the next entry in the list.
DLEntryTypeGetPrev () const
 Get the previous entry in the list.
bool IsLinked () const
 Check whether this entry is currently a member of any list.
 operator ISyncObject * ()
 Implicit conversion to a mutable pointer to the host object (T).
 operator const ISyncObject * () const
 Implicit conversion to a const pointer to the host object (T).

Protected Attributes

IWaitObject::ListHeadType m_wait_list
 tasks blocked on this object

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

Definition at line 387 of file stktest.h.

Member Typedef Documentation

◆ DLEntryType

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

◆ DLHeadType

typedef DListHead<ISyncObject, _ClosedLoop> stk::util::DListEntry< ISyncObject, _ClosedLoop >::DLHeadType
inherited

Convenience alias for the corresponding list head type.

Definition at line 75 of file stk_linked_list.h.

◆ ListEntryType

List entry type of ISyncObject elements.

Definition at line 313 of file stk_common.h.

◆ ListHeadType

List head type for ISyncObject elements.

Definition at line 308 of file stk_common.h.

Member Function Documentation

◆ AddWaitObject()

virtual void stk::ISyncObject::AddWaitObject ( IWaitObject * wobj)
inlinevirtualinherited

Called by kernel when a new task starts waiting on this event.

Parameters
[in]wobjWait object representing blocked task.

Definition at line 318 of file stk_common.h.

319 {
320 STK_ASSERT(wobj->GetHead() == nullptr);
321 m_wait_list.LinkBack(wobj);
322 }
#define STK_ASSERT(e)
Runtime assertion. Halts execution if the expression e evaluates to false.
Definition stk_defs.h:330
IWaitObject::ListHeadType m_wait_list
tasks blocked on this object
Definition stk_common.h:373

References stk::util::DListEntry< T, _ClosedLoop >::GetHead(), m_wait_list, and STK_ASSERT.

Referenced by stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelTask::WaitObject::SetupWait().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetHead()

DLHeadType * stk::util::DListEntry< ISyncObject, _ClosedLoop >::GetHead ( ) const
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 80 of file stk_linked_list.h.

80{ return m_head; }
Intrusive doubly-linked list node. Embed this as a base class in any object (T) that needs to partici...

◆ GetNext()

DLEntryType * stk::util::DListEntry< ISyncObject, _ClosedLoop >::GetNext ( ) const
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 (_ClosedLoop == true) this pointer is never NULL when the entry is linked.

Definition at line 88 of file stk_linked_list.h.

88{ return m_next; }

◆ GetPrev()

DLEntryType * stk::util::DListEntry< ISyncObject, _ClosedLoop >::GetPrev ( ) const
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 (_ClosedLoop == true) this pointer is never NULL when the entry is linked.

Definition at line 96 of file stk_linked_list.h.

96{ return m_prev; }

◆ IsLinked()

bool stk::util::DListEntry< ISyncObject, _ClosedLoop >::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 101 of file stk_linked_list.h.

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

◆ Link()

void stk::util::DListEntry< ISyncObject, _ClosedLoop >::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 137 of file stk_linked_list.h.

138 {
139 m_head = head;
140 m_next = next;
141 m_prev = prev;
142
143 if (m_prev != nullptr)
144 m_prev->m_next = this;
145
146 if (m_next != nullptr)
147 m_next->m_prev = this;
148 }
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 ISyncObject *()

stk::util::DListEntry< ISyncObject, _ClosedLoop >::operator const ISyncObject * ( ) const
inlineinherited

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

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

Definition at line 115 of file stk_linked_list.h.

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

◆ operator ISyncObject *()

stk::util::DListEntry< ISyncObject, _ClosedLoop >::operator ISyncObject* ( )
inlineinherited

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

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

Definition at line 108 of file stk_linked_list.h.

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

◆ RemoveWaitObject()

virtual void stk::ISyncObject::RemoveWaitObject ( IWaitObject * wobj)
inlinevirtualinherited

Called by kernel when a waiting task is being removed (timeout expired, wait aborted, task terminated etc.).

Parameters
[in]wobjWait object to remove from the wait list.

Reimplemented in stk::sync::Event.

Definition at line 327 of file stk_common.h.

328 {
329 STK_ASSERT(wobj->GetHead() == &m_wait_list);
330 m_wait_list.Unlink(wobj);
331 }

References stk::util::DListEntry< T, _ClosedLoop >::GetHead(), m_wait_list, and STK_ASSERT.

Referenced by stk::sync::Event::RemoveWaitObject().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Tick()

bool stk::ISyncObject::Tick ( Timeout elapsed_ticks)
inlinevirtualinherited

Called by kernel on every system tick to handle timeout logic of waiting tasks.

Implementation of ISyncObject::Tick, see ISyncObject. Placed here as it depends on hw namespace.

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
true if this synchronization object still has waiters with a finite timeout and requires further tick calls. false if the wait list is empty or all remaining waiters have infinite timeouts, signaling to the kernel that it may stop calling Tick() for this object until a new waiter is added.
Note
When this method returns false, the kernel unlinks this object from its active sync list. It will be re-linked automatically when the next waiter is added via AddWaitObject().

Definition at line 467 of file stk_arch.h.

468{
469 // note: ScopedCriticalSection usage
470 //
471 // Single-core: no critical section needed - Tick() runs inside the
472 // SysTick ISR which already executes with interrupts disabled, making
473 // re-entrancy impossible on the local core.
474 //
475 // Multi-core: critical section is required because the tick handler on
476 // each core may call Tick() concurrently for the same Semaphore instance,
477 // and ISyncObject::Tick() is not re-entrant.
478#if (STK_ARCH_CPU_COUNT > 1)
479 hw::CriticalSection::ScopedLock cs_;
480#endif
481
482 IWaitObject *itr = static_cast<IWaitObject *>(m_wait_list.GetFirst());
483
484 while (itr != nullptr)
485 {
486 IWaitObject *next = static_cast<IWaitObject *>(itr->GetNext());
487
488 if (!itr->Tick(elapsed_ticks))
489 itr->Wake(true);
490
491 itr = next;
492 }
493
494 return !m_wait_list.IsEmpty();
495}

References stk::util::DListEntry< T, _ClosedLoop >::GetNext(), m_wait_list, stk::IWaitObject::Tick(), and stk::IWaitObject::Wake().

Here is the call graph for this function:

◆ Unlink()

void stk::util::DListEntry< ISyncObject, _ClosedLoop >::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 157 of file stk_linked_list.h.

158 {
159 if (m_prev != nullptr)
161
162 if (m_next != nullptr)
164
165 m_head = nullptr;
166 m_next = nullptr;
167 m_prev = nullptr;
168 }

◆ WakeAll()

void stk::test::SyncObjectMock::WakeAll ( )
inline

Definition at line 390 of file stktest.h.

void WakeAll()
Wake all tasks currently in the wait list.
Definition stk_common.h:367

References stk::ISyncObject::WakeAll().

Here is the call graph for this function:

◆ WakeOne()

void stk::test::SyncObjectMock::WakeOne ( )
inline

Definition at line 389 of file stktest.h.

void WakeOne()
Wake the first task in the wait list (FIFO order).
Definition stk_common.h:357

References stk::ISyncObject::WakeOne().

Here is the call graph for this function:

Member Data Documentation

◆ m_head

DLHeadType* stk::util::DListEntry< ISyncObject, _ClosedLoop >::m_head
privateinherited

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

Definition at line 170 of file stk_linked_list.h.

◆ m_next

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

◆ m_prev

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

◆ m_wait_list


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