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

Scoped, read-only lock for thread-safe access to DataItems. More...

#include <ReadLock.h>

Public Member Functions

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

Detailed Description

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.

Date
2012-01-20

Definition at line 37 of file ReadLock.h.

Constructor & Destructor Documentation

◆ ReadLock() [1/2]

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.

◆ ReadLock() [2/2]

Mantid::Kernel::ReadLock::ReadLock ( const ReadLock )
delete

◆ ~ReadLock()

Mantid::Kernel::ReadLock::~ReadLock ( )
virtual

Destructor.

Definition at line 25 of file ReadLock.cpp.

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

Member Function Documentation

◆ operator new()

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

Disallow creating the object on the heap.

◆ operator new[]()

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

Disallow creating the object on the heap.

◆ operator=()

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

Member Data Documentation

◆ m_item

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

Reference to the data item we are locking.

Definition at line 51 of file ReadLock.h.

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


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