OpendTect  6.6
Public Member Functions | Protected Attributes | List of all members
MonitorLock Class Reference

protects a MonitoredObject against change. More...

Public Member Functions

 MonitorLock (const MonitoredObject &)
 
 ~MonitorLock ()
 
void reLock ()
 
void unlockNow ()
 

Protected Attributes

MonitoredObject::AccessLocker locker_
 
bool unlocked_
 

Detailed Description

protects a MonitoredObject against change.

Compare the locking with thread-locking tools:

1) The MonitoredObject has (should have) methods that make a method call sort-of atomic. You call it, and are guaranteed the whole operation succeeds safely without interruption.

2) Sometimes operations on MonitoredObject's are dependent on each other. For example, when you are iterating through a list. If changes in the list (size of list, or elements changing) are unacceptable, you need a tool to prevent any change. This is the MonitorLock.

Note that not releasing the lock will almost certainly stop the entire app, therefore the MonitorLock will always release when it goes out of scope. Most often though you want to release asap, therefore you'll often call unlockNow() immediately when done.

Beware: you cannot use the MonitorLock and still change the object, a DEADLOCK will be your reward. To write while reading, make a copy of the object, change it, and assign the object to that. The assignment operator of the object should be 'atomic' again, thanks to the assignment operator macros.

<>

Constructor & Destructor Documentation

◆ MonitorLock()

MonitorLock::MonitorLock ( const MonitoredObject )

◆ ~MonitorLock()

MonitorLock::~MonitorLock ( )

Member Function Documentation

◆ reLock()

void MonitorLock::reLock ( )

◆ unlockNow()

void MonitorLock::unlockNow ( )

Member Data Documentation

◆ locker_

MonitoredObject::AccessLocker MonitorLock::locker_
protected

◆ unlocked_

bool MonitorLock::unlocked_
protected

Generated at for the OpendTect seismic interpretation project. Copyright (C): dGB Beheer B.V. 1995-2022