10#ifndef STK_SYNC_EVENT_FLAGS_H_
11#define STK_SYNC_EVENT_FLAGS_H_
154 uint32_t
Set(uint32_t flags);
163 uint32_t
Clear(uint32_t flags);
171 uint32_t
Get()
const;
222 return ((
m_flags & flags) == flags);
224 return ((
m_flags & flags) != 0U);
237 if ((flags == 0U) || ((flags &
ERROR_MASK) != 0U))
243 const uint32_t result =
m_flags;
257 if ((flags == 0U) || ((flags &
ERROR_MASK) != 0U))
286 if ((flags == 0U) || ((flags &
ERROR_MASK) != 0U))
309 remaining = (now >= deadline ?
NO_WAIT : (deadline - now));
312 if (!
m_cv.Wait(cs_, remaining))
#define STK_ASSERT(e)
Runtime assertion. Halts execution if the expression e evaluates to false.
Implementation of synchronization primitive: stk::sync::ConditionVariable.
Namespace of STK package.
const Timeout WAIT_INFINITE
Timeout value: block indefinitely until the synchronization object is signaled.
Ticks GetTicks()
Get number of ticks elapsed since kernel start.
int32_t Timeout
Timeout time (ticks).
const Timeout NO_WAIT
Timeout value: return immediately if the synchronization object is not yet signaled (non-blocking pol...
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=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
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.
STK_NONCOPYABLE_CLASS(EventFlags)
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.