AGX Dynamics 2.42.3.1
Loading...
Searching...
No Matches
agx::ReaderWriterLock Class Reference

ReaderWriterLock provides shared access for readers and exclusive access for writers. More...

#include <ThreadSynchronization.h>

Public Member Functions

 ReaderWriterLock ()
 Constructor.
 
 ReaderWriterLock (const ReaderWriterLock &)=delete
 
void lock ()
 Acquire exclusive access.
 
void lock_shared ()
 Acquire the shared lock.
 
ReaderWriterLock & operator= (const ReaderWriterLock &)=delete
 
void unlock ()
 Relese the exclusive access.
 
void unlock_shared ()
 Releases the shared access.
 

Detailed Description

ReaderWriterLock provides shared access for readers and exclusive access for writers.

A thread is not allowed to upgrade or downgrade their lock type. For example, if a shared access is taken via lock_shared, it must then be released via unlock_shared before exclusive access can be requested.

If c++17 is available, std::shared_mutex is recommended instead of this class.

Definition at line 154 of file ThreadSynchronization.h.

Constructor & Destructor Documentation

◆ ReaderWriterLock() [1/2]

agx::ReaderWriterLock::ReaderWriterLock ( )

Constructor.

◆ ReaderWriterLock() [2/2]

agx::ReaderWriterLock::ReaderWriterLock ( const ReaderWriterLock &  )
delete

Member Function Documentation

◆ lock()

void agx::ReaderWriterLock::lock ( )

Acquire exclusive access.

◆ lock_shared()

void agx::ReaderWriterLock::lock_shared ( )

Acquire the shared lock.

Multiple threads can have shared access at the same time. For example used by multiple readers.

◆ operator=()

ReaderWriterLock & agx::ReaderWriterLock::operator= ( const ReaderWriterLock &  )
delete

◆ unlock()

void agx::ReaderWriterLock::unlock ( )

Relese the exclusive access.

◆ unlock_shared()

void agx::ReaderWriterLock::unlock_shared ( )

Releases the shared access.


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