10#ifndef STK_SYNC_BARRIER_H_
11#define STK_SYNC_BARRIER_H_
#define STK_NONCOPYABLE_CLASS(TYPE)
Disables copy construction and assignment for a class.
#define STK_ASSERT(e)
Runtime assertion. Halts execution if the expression e evaluates to false.
#define STK_VIRT_DTOR
Makes destructors virtual and compliant to strict rules if STK_STRICT_COMPLIANCY=0.
Implementation of synchronization primitive: stk::sync::ConditionVariable.
Implementation of synchronization primitive: stk::sync::Mutex.
Namespace of STK package.
@ WAIT_RESULT_CANCELED
The wait was cancelled by another task via IKernel::CancelTaskWait(), independent of signal/timeout.
static constexpr Timeout WAIT_INFINITE
Timeout value: block indefinitely until the synchronization object is signaled.
bool IsInsideISR()
Check whether the CPU is currently executing inside a hardware interrupt service routine (ISR).
Synchronization primitives for task coordination and resource protection.
uint32_t m_count
number of tasks still to arrive in the current generation
Barrier(uint32_t count)
Constructor.
uint32_t GetThreshold() const
Get the number of tasks required to trip the barrier.
ConditionVariable m_cond
signals waiting tasks when the current generation completes
uint32_t m_generation
generation counter, incremented every time the barrier trips
bool Wait()
Block the calling task until count tasks have called Wait().
EResult
Outcome of a Barrier::WaitEx() call.
@ BARRIER_LAST_ARRIVAL
This task was the last arrival and tripped the barrier.
@ BARRIER_RELEASED
Released because the barrier tripped; this task was not the last arrival.
const uint32_t m_threshold
number of tasks required to trip the barrier
Mutex m_mutex
protects m_count / m_generation and serializes calls to m_cond
EResult WaitEx()
Block the calling task until count tasks have called Wait(), preserving the full outcome.
Condition Variable primitive for signaling between tasks based on specific predicates.
Recursive mutex primitive that allows the same thread to acquire the lock multiple times.