Mantid
|
Scoped, read-only lock for thread-safe access to DataItems. More...
#include <ReadLock.h>
Public Member Functions | |
ReadLock & | operator= (const ReadLock &)=delete |
ReadLock (const DataItem &item) | |
Constructor. More... | |
ReadLock (const ReadLock &)=delete | |
virtual | ~ReadLock () |
Destructor. More... | |
Private Member Functions | |
void * | operator new (size_t) |
Disallow creating the object on the heap. More... | |
void * | operator new[] (size_t) |
Disallow creating the object on the heap. More... | |
Private Attributes | |
const DataItem & | m_item |
Reference to the data item we are locking. More... | |
Scoped, read-only lock for thread-safe access to DataItems.
Acquire a ReadLock on any DataItem (e.g. a Workspace) that you are going to be reading in a thread. This prevents any thread from acquiring a Write lock on it, and blocks until any write lock is unlocked.
The read lock is automatically unlocked when the variable goes out of scope (in the destructor).
Sample Usage: { ReadLock _lock(*workspace_sptr); // Read the workspace } // Lock has been released when _lock when out of scope.
Definition at line 37 of file ReadLock.h.
Mantid::Kernel::ReadLock::ReadLock | ( | const DataItem & | item | ) |
Constructor.
Definition at line 17 of file ReadLock.cpp.
References m_item, and Mantid::Kernel::DataItem::m_lock.
|
delete |
|
virtual |
Destructor.
Definition at line 25 of file ReadLock.cpp.
References m_item, and Mantid::Kernel::DataItem::m_lock.
|
private |
Disallow creating the object on the heap.
|
private |
Disallow creating the object on the heap.
|
private |
Reference to the data item we are locking.
Definition at line 51 of file ReadLock.h.
Referenced by ReadLock(), and ~ReadLock().