PCL
pcl::ReadWriteMutex Class Reference

Client-side interface to a PixInsight read/write mutex object. More...

#include <ReadWriteMutex.h>

+ Inheritance diagram for pcl::ReadWriteMutex:

Public Member Functions

 ReadWriteMutex ()
 
 ReadWriteMutex (const ReadWriteMutex &)=delete
 
virtual ~ReadWriteMutex ()
 
void EnsureUnique () override
 
void LockForRead ()
 
void LockForWrite ()
 
ReadWriteMutexoperator= (const ReadWriteMutex &)=delete
 
bool TryLockForRead ()
 
bool TryLockForWrite ()
 
void Unlock ()
 
- Public Member Functions inherited from pcl::UIObject
virtual ~UIObject () noexcept(false)
 
bool IsAlias () const
 
bool IsGarbage () const
 
bool IsNull () const
 
bool IsSameObject (const UIObject &o) const
 
bool IsUnique () const
 
String ObjectId () const
 
IsoString ObjectType () const
 
bool operator< (const UIObject &o) const
 
bool operator== (const UIObject &o) const
 
size_type RefCount () const
 
void SetObjectId (const String &id)
 

Static Public Member Functions

static ReadWriteMutexNull ()
 
- Static Public Member Functions inherited from pcl::UIObject
static UIObjectNull ()
 

Additional Inherited Members

- Protected Member Functions inherited from pcl::UIObject
 UIObject ()=default
 
 UIObject (const UIObject &x)
 
 UIObject (UIObject &&x)
 
UIObjectoperator= (const UIObject &x)
 
UIObjectoperator= (UIObject &&x)
 

Detailed Description

ReadWriteMutex provides separate thread synchronization for read and write operations. This can be more efficient than plain Mutex synchronization because multiple threads can access a data item for read-only operations simultaneously, which in turn improves concurrency if write accesses are relatively infrequent.

See also
Mutex

Definition at line 79 of file ReadWriteMutex.h.

Constructor & Destructor Documentation

◆ ReadWriteMutex() [1/2]

pcl::ReadWriteMutex::ReadWriteMutex ( )

Constructs a ReadWriteMutex object.

◆ ~ReadWriteMutex()

virtual pcl::ReadWriteMutex::~ReadWriteMutex ( )
inlinevirtual

Destroys a ReadWriteMutex object.

Warning
Destroying a locked ReadWriteMutex object may result in undefined (mostly catastrophic) behavior. Always ensure that a read/write mutex has been unlocked before destroying it.

Definition at line 95 of file ReadWriteMutex.h.

◆ ReadWriteMutex() [2/2]

pcl::ReadWriteMutex::ReadWriteMutex ( const ReadWriteMutex )
delete

Copy constructor. This constructor is disabled because ReadWriteMutex represents unique server-side objects.

Member Function Documentation

◆ EnsureUnique()

void pcl::ReadWriteMutex::EnsureUnique ( )
inlineoverridevirtual

Ensures that the server-side object managed by this instance is uniquely referenced.

Since mutexes are unique objects by definition, calling this member function has no effect.

Reimplemented from pcl::UIObject.

Definition at line 118 of file ReadWriteMutex.h.

◆ LockForRead()

void pcl::ReadWriteMutex::LockForRead ( )

Locks this read/write mutex object for reading.

The calling thread will block its execution if other thread has locked this read/write mutex for writing.

◆ LockForWrite()

void pcl::ReadWriteMutex::LockForWrite ( )

Locks this read/write mutex object for writing.

The calling thread will block its execution if other thread has locked this read/write mutex for reading or writing.

◆ Null()

static ReadWriteMutex& pcl::ReadWriteMutex::Null ( )
static

Returns a reference to a null ReadWriteMutex instance. A null ReadWriteMutex does not correspond to an existing read/write mutex in the PixInsight core application.

◆ operator=()

ReadWriteMutex& pcl::ReadWriteMutex::operator= ( const ReadWriteMutex )
delete

Copy assignment. This operator is disabled because ReadWriteMutex represents unique server-side objects.

◆ TryLockForRead()

bool pcl::ReadWriteMutex::TryLockForRead ( )

Attempts locking this read/write mutex object for reading. Returns true if this mutex has been successfully locked by the calling thread, false otherwise.

Locking for reading will only fail if other thread has locked this object for writing. If other threads have locked this object for reading only, the calling thread will also lock it and this function will return true.

Unlike LockForRead(), this function does not block execution of the calling thread if this ReadWriteMutex cannot be locked for reading.

◆ TryLockForWrite()

bool pcl::ReadWriteMutex::TryLockForWrite ( )

Attempts locking this read/write mutex object for writing. Returns true if this mutex has been successfully locked by the calling thread, false otherwise.

Locking for writing will fail if other thread has locked this object for reading or writing.

Unlike LockForWrite(), this function does not block execution of the calling thread if this ReadWriteMutex cannot be locked for writing.

◆ Unlock()

void pcl::ReadWriteMutex::Unlock ( )

Unlocks this ReadWriteMutex object.


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