![]() |
SuperTinyKernel™ RTOS 1.08.x
Lightweight, high-performance, deterministic, bare-metal C++ RTOS for resource-constrained embedded systems. MIT Open Source License.
|
Cyclic barrier that blocks a fixed-size group of tasks until all of them have arrived. More...
#include <stk_sync_barrier.h>
Public Member Functions | |
| Barrier (uint32_t count) | |
| Constructor. | |
| ~Barrier () | |
| Destructor. | |
| bool | Wait () |
Block the calling task until count tasks have called Wait(). | |
| uint32_t | GetThreshold () const |
| Get the number of tasks required to trip the barrier. | |
| void | SetTraceName (const char *name) |
| Set name. | |
| const char * | GetTraceName () const |
| Get name. | |
Private Member Functions | |
| Barrier (const Barrier &)=delete | |
| Barrier & | operator= (const Barrier &)=delete |
Private Attributes | |
| Mutex | m_mutex |
| protects m_count / m_generation and serializes calls to m_cond | |
| ConditionVariable | m_cond |
| signals waiting tasks when the current generation completes | |
| const uint32_t | m_threshold |
| number of tasks required to trip the barrier | |
| uint32_t | m_count |
| number of tasks still to arrive in the current generation | |
| uint32_t | m_generation |
| generation counter, incremented every time the barrier trips | |
Cyclic barrier that blocks a fixed-size group of tasks until all of them have arrived.
A Barrier lets a set of count tasks rendezvous at a common point: each task calls Wait() and blocks until the last member of the group also calls Wait(). Once the last task arrives, all waiting tasks are released simultaneously and the barrier automatically resets (cyclic behavior), ready to be reused for the next round.
Definition at line 54 of file stk_sync_barrier.h.
|
inlineexplicit |
Constructor.
| [in] | count | Number of tasks that must call Wait() before any of them is released. |
Definition at line 61 of file stk_sync_barrier.h.
References m_count, m_generation, m_threshold, and STK_ASSERT.
Referenced by Barrier().
|
inline |
|
privatedelete |
|
inline |
Get the number of tasks required to trip the barrier.
Definition at line 83 of file stk_sync_barrier.h.
References m_threshold.
Referenced by stk_barrier_get_threshold().
|
inlineinherited |
Get name.
NULL if not set or if STK_SYNC_DEBUG_NAMES is 0. Definition at line 534 of file stk_common.h.
|
inlineinherited |
Set name.
| [in] | name | Null-terminated string or NULL. |
Definition at line 522 of file stk_common.h.
References STK_UNUSED.
Referenced by stk::memory::BlockMemoryPool::BlockMemoryPool(), and stk::memory::BlockMemoryPool::BlockMemoryPool().
|
inline |
Block the calling task until count tasks have called Wait().
Once the last task arrives, all currently waiting tasks are woken up and the barrier resets itself so it can be reused for the next round.
Definition at line 99 of file stk_sync_barrier.h.
References stk::hw::IsInsideISR(), m_cond, m_count, m_generation, m_mutex, m_threshold, STK_ASSERT, STK_UNUSED, and stk::WAIT_INFINITE.
Referenced by stk_barrier_wait().
|
private |
signals waiting tasks when the current generation completes
Definition at line 89 of file stk_sync_barrier.h.
Referenced by Wait().
|
private |
number of tasks still to arrive in the current generation
Definition at line 91 of file stk_sync_barrier.h.
|
private |
generation counter, incremented every time the barrier trips
Definition at line 92 of file stk_sync_barrier.h.
|
private |
protects m_count / m_generation and serializes calls to m_cond
Definition at line 88 of file stk_sync_barrier.h.
Referenced by Wait().
|
private |
number of tasks required to trip the barrier
Definition at line 90 of file stk_sync_barrier.h.
Referenced by Barrier(), GetThreshold(), and Wait().