10#ifndef STK_SYNC_EVENT_FLAGS_H_
11#define STK_SYNC_EVENT_FLAGS_H_
150 uint32_t
Set(uint32_t flags);
159 uint32_t
Clear(uint32_t flags);
167 uint32_t
Get()
const;
233 if ((flags != 0U) && ((flags &
ERROR_MASK) == 0U))
255 if ((flags != 0U) && ((flags &
ERROR_MASK) == 0U))
283 uint32_t final_result = 0U;
286 if ((flags == 0U) || ((flags &
ERROR_MASK) != 0U))
302 const Timeout deadline = (timed_wait ?
314 remaining = (now >= deadline ?
NO_WAIT : (deadline - now));
317 if (!
m_cv.Wait(cs_, remaining))
#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.
Namespace of STK package.
constexpr Timeout NO_WAIT
Timeout value: return immediately if the synchronization object is not yet signaled (non-blocking pol...
int32_t Timeout
Timeout time (ticks).
static Ticks GetTicks()
Get number of ticks elapsed since kernel start.
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.
RAII-style low-level synchronization primitive for atomic code execution. Used as building brick for ...
Condition Variable primitive for signaling between tasks based on specific predicates.
uint32_t Wait(uint32_t flags, uint32_t options=OPT_WAIT_ANY, Timeout timeout_ticks=WAIT_INFINITE)
Wait for one or more flags to be set.
uint32_t Get() const
Read the current flags word without modifying it.
ConditionVariable m_cv
woken by Set() to re-evaluate waiting tasks
~EventFlags()=default
Destructor.
volatile uint32_t m_flags
32-bit flags word (bit 31 is reserved for errors)
uint32_t TryWait(uint32_t flags, uint32_t options=OPT_WAIT_ANY)
Non-blocking flag poll.
static const uint32_t ERROR_ISR
Return sentinel: called from an ISR with a blocking timeout.
static const uint32_t ERROR_TIMEOUT
Return sentinel: wait timed out before the flags condition was met.
static bool IsError(uint32_t result)
Checks if a return value from Set(), Clear(), or Wait() is an error.
static const uint32_t OPT_NO_CLEAR
Do not clear matched flags after a successful wait.
static const uint32_t ERROR_PARAMETER
Return sentinel: invalid flags argument (bit 31 set).
static const uint32_t OPT_WAIT_ALL
Wait for ALL of the specified flags to be set simultaneously (AND semantics).
bool IsSatisfied(uint32_t flags, uint32_t options) const
EventFlags(uint32_t initial_flags=0U)
Constructor.
uint32_t Clear(uint32_t flags)
Clear one or more flags.
static const uint32_t OPT_WAIT_ANY
Wait for ANY of the specified flags to be set (OR semantics, default).
uint32_t Set(uint32_t flags)
Set one or more flags.
static const uint32_t ERROR_MASK
Reserved error mask. Any return value with bit 31 set is an error.