PCL
|
Client-side interface to a PixInsight read/write mutex object. More...
#include <ReadWriteMutex.h>
Public Member Functions | |
ReadWriteMutex () | |
ReadWriteMutex (const ReadWriteMutex &)=delete | |
~ReadWriteMutex () override | |
void | EnsureUnique () override |
void | LockForRead () |
void | LockForWrite () |
ReadWriteMutex & | operator= (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 ReadWriteMutex & | Null () |
Static Public Member Functions inherited from pcl::UIObject | |
static UIObject & | Null () |
Additional Inherited Members | |
Protected Member Functions inherited from pcl::UIObject | |
UIObject ()=default | |
UIObject (const UIObject &x) | |
UIObject (UIObject &&x) | |
UIObject & | operator= (const UIObject &x) |
UIObject & | operator= (UIObject &&x) |
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.
Definition at line 79 of file ReadWriteMutex.h.
pcl::ReadWriteMutex::ReadWriteMutex | ( | ) |
Constructs a ReadWriteMutex object.
|
inlineoverride |
Destroys a ReadWriteMutex object.
Definition at line 95 of file ReadWriteMutex.h.
|
delete |
Copy constructor. This constructor is disabled because ReadWriteMutex represents unique server-side objects.
|
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.
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.
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.
|
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.
|
delete |
Copy assignment. This operator is disabled because ReadWriteMutex represents unique server-side objects.
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.
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.
void pcl::ReadWriteMutex::Unlock | ( | ) |
Unlocks this ReadWriteMutex object.