Mantid
|
Scoped write-lock for thread-safe access to DataItems. More...
#include <WriteLock.h>
Public Member Functions | |
WriteLock & | operator= (const WriteLock &)=delete |
WriteLock (const DataItem &item) | |
Constructor. More... | |
WriteLock (const WriteLock &)=delete | |
virtual | ~WriteLock () |
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 write-lock for thread-safe access to DataItems.
Acquire a WriteLock on a workspace that you will be modifying. This blocks any other thread from reading/writing to the workspace.
Note that normally, you SHOULD NOT CALL THIS IN AN ALGORITHM, because read- or write-locking of the input or output workspaces is taken care of in the Algorithm class.
The write lock is automatically unlocked when the variable goes out of scope (in the destructor). Multiple read-locks can be acquired simultaneously, but only one write-lock.
Sample Usage: { WriteLock _lock(*workspace_sptr); // Modify the workspace } // Lock has been released when _lock when out of scope.
Definition at line 41 of file WriteLock.h.
Mantid::Kernel::WriteLock::WriteLock | ( | const DataItem & | item | ) |
Constructor.
Definition at line 16 of file WriteLock.cpp.
References m_item, and Mantid::Kernel::DataItem::m_lock.
|
delete |
|
virtual |
Destructor.
Definition at line 24 of file WriteLock.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 55 of file WriteLock.h.
Referenced by WriteLock(), and ~WriteLock().