SuperTinyKernel™ RTOS 1.06.x
Lightweight, high-performance, deterministic, bare-metal C++ RTOS for resource-constrained embedded systems. MIT Open Source License.
Loading...
Searching...
No Matches
stk::sync::RWMutex::ScopedTimedLock Class Reference

RAII wrapper for attempting exclusive write access with a timeout. More...

#include <stk_sync_rwmutex.h>

Collaboration diagram for stk::sync::RWMutex::ScopedTimedLock:

Public Member Functions

 ScopedTimedLock (RWMutex &rw, Timeout timeout_ticks=WAIT_INFINITE)
 Constructs the guard and attempts to acquire the write lock.
 ~ScopedTimedLock ()
bool IsLocked () const

Private Member Functions

 ScopedTimedLock (const ScopedTimedLock &)=delete
ScopedTimedLockoperator= (const ScopedTimedLock &)=delete

Private Attributes

RWMutexm_rw
bool m_locked

Detailed Description

RAII wrapper for attempting exclusive write access with a timeout.

Definition at line 85 of file stk_sync_rwmutex.h.

Constructor & Destructor Documentation

◆ ScopedTimedLock() [1/2]

stk::sync::RWMutex::ScopedTimedLock::ScopedTimedLock ( RWMutex & rw,
Timeout timeout_ticks = WAIT_INFINITE )
inlineexplicit

Constructs the guard and attempts to acquire the write lock.

Parameters
[in]rwReference to the RWMutex.
[in]timeout_ticksMaximum time to wait (ticks). Use NO_WAIT for non-blocking (TryLock).

Definition at line 92 of file stk_sync_rwmutex.h.

93 : m_rw(rw), m_locked(rw.TimedLock(timeout_ticks))
94 {}

References m_locked, m_rw, stk::sync::RWMutex::RWMutex(), stk::sync::RWMutex::TimedLock(), and stk::WAIT_INFINITE.

Referenced by operator=().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ~ScopedTimedLock()

stk::sync::RWMutex::ScopedTimedLock::~ScopedTimedLock ( )
inline

Definition at line 96 of file stk_sync_rwmutex.h.

96{ if (m_locked) { m_rw.Unlock(); } }

References m_locked, and m_rw.

◆ ScopedTimedLock() [2/2]

stk::sync::RWMutex::ScopedTimedLock::ScopedTimedLock ( const ScopedTimedLock & )
privatedelete

Member Function Documentation

◆ IsLocked()

bool stk::sync::RWMutex::ScopedTimedLock::IsLocked ( ) const
inline

Definition at line 98 of file stk_sync_rwmutex.h.

98{ return m_locked; }

References m_locked.

◆ operator=()

ScopedTimedLock & stk::sync::RWMutex::ScopedTimedLock::operator= ( const ScopedTimedLock & )
privatedelete

References ScopedTimedLock().

Here is the call graph for this function:

Member Data Documentation

◆ m_locked

bool stk::sync::RWMutex::ScopedTimedLock::m_locked
private

Definition at line 104 of file stk_sync_rwmutex.h.

Referenced by IsLocked(), ScopedTimedLock(), and ~ScopedTimedLock().

◆ m_rw

RWMutex& stk::sync::RWMutex::ScopedTimedLock::m_rw
private

Definition at line 103 of file stk_sync_rwmutex.h.

Referenced by ScopedTimedLock(), and ~ScopedTimedLock().


The documentation for this class was generated from the following file: