10#ifndef STK_SYNC_RWMUTEX_H_
11#define STK_SYNC_RWMUTEX_H_
#define STK_UNUSED(X)
Explicitly marks a variable as unused to suppress compiler warnings.
#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 __stk_forceinline void STK_KERNEL_PANIC(stk::EKernelPanicId id)
Called when the kernel detects an unrecoverable internal fault.
constexpr Timeout WAIT_INFINITE
Timeout value: block indefinitely until the synchronization object is signaled.
@ KERNEL_PANIC_ASSERT
Internal assertion failed (maps from STK_ASSERT).
Synchronization primitives for task coordination and resource protection.
Interface for mutex synchronization primitive.
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.
static const uint16_t READERS_MAX
maximum number of concurrent readers
bool TryLock()
Attempt to acquire the lock for exclusive writing without blocking.
bool TimedLock(Timeout timeout_ticks)
Acquire the lock for exclusive writing with a timeout.
ConditionVariable m_cv_writers
signaled when a writer can proceed
bool m_writer_active
true if a writer currently holds the lock
static const uint16_t WRITERS_MAX
maximum number of waiting writers
void Unlock() override
Release the exclusive writer lock (IMutex interface).
uint16_t m_writers_waiting
count of writers waiting for access
void Lock() override
Acquire the lock for exclusive writing (IMutex interface).
uint16_t m_readers
current active reader count
RWMutex()
Construct an RWMutex in the unlocked state with no active readers or writers.
bool TimedReadLock(Timeout timeout_ticks)
Acquire the lock for shared reading with a timeout.
ConditionVariable m_cv_readers
signaled when readers can proceed
void ReadUnlock()
Release the shared reader lock.
void ReadLock()
Acquire the lock for shared reading.
bool TryReadLock()
Attempt to acquire the lock for shared reading without blocking.
ScopedTimedLock(RWMutex &rw, Timeout timeout_ticks=WAIT_INFINITE)
Constructs the guard and attempts to acquire the write lock.
ScopedTimedReadMutex(RWMutex &rw, Timeout timeout_ticks=WAIT_INFINITE)
Constructs the guard and attempts to acquire the read lock.