Internal Interface Wrap
API reference
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
PlatformSharedMutexImpl< Backend > Class Template Reference

Reader-writer mutex using two regular mutexes + atomic counters. More...

#include <PlatformMutex.h>

Public Member Functions

 PlatformSharedMutexImpl () noexcept
 
 ~PlatformSharedMutexImpl () noexcept
 
 PlatformSharedMutexImpl (const PlatformSharedMutexImpl &)=delete
 
PlatformSharedMutexImpl & operator= (const PlatformSharedMutexImpl &)=delete
 
 PlatformSharedMutexImpl (PlatformSharedMutexImpl &&other) noexcept
 
PlatformSharedMutexImpl & operator= (PlatformSharedMutexImpl &&other) noexcept
 
bool lock () noexcept
 
bool try_lock () noexcept
 
bool try_lock_for (uint32_t timeout_ms) noexcept
 
void unlock () noexcept
 
bool lock_shared () noexcept
 
bool try_lock_shared () noexcept
 
bool try_lock_shared_for (uint32_t timeout_ms) noexcept
 
void unlock_shared () noexcept
 

Private Attributes

Backend::MutexHandle writer_mutex_
 
Backend::MutexHandle reader_mutex_
 
std::atomic< int > readers_
 
std::atomic< bool > writer_active_
 

Detailed Description

template<typename Backend = PlatformMutexActiveBackend>
class PlatformSharedMutexImpl< Backend >

Reader-writer mutex using two regular mutexes + atomic counters.

Multiple readers can hold the lock concurrently; writers have exclusive access. When Backend = NullMutexBackend, all operations compile away.

Template Parameters
BackendStatic policy class satisfying the NullMutexBackend contract.

Constructor & Destructor Documentation

◆ PlatformSharedMutexImpl() [1/3]

template<typename Backend = PlatformMutexActiveBackend>
PlatformSharedMutexImpl< Backend >::PlatformSharedMutexImpl ( )
inlinenoexcept

◆ ~PlatformSharedMutexImpl()

template<typename Backend = PlatformMutexActiveBackend>
PlatformSharedMutexImpl< Backend >::~PlatformSharedMutexImpl ( )
inlinenoexcept

◆ PlatformSharedMutexImpl() [2/3]

template<typename Backend = PlatformMutexActiveBackend>
PlatformSharedMutexImpl< Backend >::PlatformSharedMutexImpl ( const PlatformSharedMutexImpl< Backend > &  )
delete

◆ PlatformSharedMutexImpl() [3/3]

template<typename Backend = PlatformMutexActiveBackend>
PlatformSharedMutexImpl< Backend >::PlatformSharedMutexImpl ( PlatformSharedMutexImpl< Backend > &&  other)
inlinenoexcept

Member Function Documentation

◆ lock()

template<typename Backend = PlatformMutexActiveBackend>
bool PlatformSharedMutexImpl< Backend >::lock ( )
inlinenoexcept

◆ lock_shared()

template<typename Backend = PlatformMutexActiveBackend>
bool PlatformSharedMutexImpl< Backend >::lock_shared ( )
inlinenoexcept

◆ operator=() [1/2]

template<typename Backend = PlatformMutexActiveBackend>
PlatformSharedMutexImpl & PlatformSharedMutexImpl< Backend >::operator= ( const PlatformSharedMutexImpl< Backend > &  )
delete

◆ operator=() [2/2]

template<typename Backend = PlatformMutexActiveBackend>
PlatformSharedMutexImpl & PlatformSharedMutexImpl< Backend >::operator= ( PlatformSharedMutexImpl< Backend > &&  other)
inlinenoexcept

◆ try_lock()

template<typename Backend = PlatformMutexActiveBackend>
bool PlatformSharedMutexImpl< Backend >::try_lock ( )
inlinenoexcept

◆ try_lock_for()

template<typename Backend = PlatformMutexActiveBackend>
bool PlatformSharedMutexImpl< Backend >::try_lock_for ( uint32_t  timeout_ms)
inlinenoexcept

◆ try_lock_shared()

template<typename Backend = PlatformMutexActiveBackend>
bool PlatformSharedMutexImpl< Backend >::try_lock_shared ( )
inlinenoexcept

◆ try_lock_shared_for()

template<typename Backend = PlatformMutexActiveBackend>
bool PlatformSharedMutexImpl< Backend >::try_lock_shared_for ( uint32_t  timeout_ms)
inlinenoexcept

◆ unlock()

template<typename Backend = PlatformMutexActiveBackend>
void PlatformSharedMutexImpl< Backend >::unlock ( )
inlinenoexcept

◆ unlock_shared()

template<typename Backend = PlatformMutexActiveBackend>
void PlatformSharedMutexImpl< Backend >::unlock_shared ( )
inlinenoexcept

Member Data Documentation

◆ reader_mutex_

template<typename Backend = PlatformMutexActiveBackend>
Backend::MutexHandle PlatformSharedMutexImpl< Backend >::reader_mutex_
private

◆ readers_

template<typename Backend = PlatformMutexActiveBackend>
std::atomic<int> PlatformSharedMutexImpl< Backend >::readers_
private

◆ writer_active_

template<typename Backend = PlatformMutexActiveBackend>
std::atomic<bool> PlatformSharedMutexImpl< Backend >::writer_active_
private

◆ writer_mutex_

template<typename Backend = PlatformMutexActiveBackend>
Backend::MutexHandle PlatformSharedMutexImpl< Backend >::writer_mutex_
private

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