Mantid
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Mantid::Kernel::WriteLock Class Reference

Scoped write-lock for thread-safe access to DataItems. More...

#include <WriteLock.h>

Public Member Functions

WriteLockoperator= (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 DataItemm_item
 Reference to the data item we are locking. More...
 

Detailed Description

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.

Date
2012-01-20

Definition at line 41 of file WriteLock.h.

Constructor & Destructor Documentation

◆ WriteLock() [1/2]

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.

◆ WriteLock() [2/2]

Mantid::Kernel::WriteLock::WriteLock ( const WriteLock )
delete

◆ ~WriteLock()

Mantid::Kernel::WriteLock::~WriteLock ( )
virtual

Destructor.

Definition at line 24 of file WriteLock.cpp.

References m_item, and Mantid::Kernel::DataItem::m_lock.

Member Function Documentation

◆ operator new()

void * Mantid::Kernel::WriteLock::operator new ( size_t  )
private

Disallow creating the object on the heap.

◆ operator new[]()

void * Mantid::Kernel::WriteLock::operator new[] ( size_t  )
private

Disallow creating the object on the heap.

◆ operator=()

WriteLock & Mantid::Kernel::WriteLock::operator= ( const WriteLock )
delete

Member Data Documentation

◆ m_item

const DataItem& Mantid::Kernel::WriteLock::m_item
private

Reference to the data item we are locking.

Definition at line 55 of file WriteLock.h.

Referenced by WriteLock(), and ~WriteLock().


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