Ocean
Ocean::OptionalScopedLock Class Reference

This class implements an optional recursive scoped lock object locking the lock object only if it's defined. More...

Public Member Functions

 OptionalScopedLock (Lock *lock)
 Creates a new optional scoped lock object by a given lock object. More...
 
 OptionalScopedLock (Lock &lock, const bool apply)
 Creates a new optional scoped lock object by a given lock object and a boolean statement whether the lock is invoked or not. More...
 
 ~OptionalScopedLock ()
 Destructs an optional scoped lock and unlocks the internal lock object if defined. More...
 
Locklock () const
 Returns the lock object which (if existing) is locked during the existence of this scoped lock object. More...
 

Protected Member Functions

 OptionalScopedLock (const OptionalScopedLock &object)=delete
 Disabled accessible copy operator. More...
 
OptionalScopedLockoperator= (const OptionalScopedLock &object)=delete
 Disabled accessible assigns operator. More...
 

Protected Attributes

Locklock_ = nullptr
 Lock object which is locked during the existence of this scoped lock object. More...
 

Detailed Description

This class implements an optional recursive scoped lock object locking the lock object only if it's defined.

See also
Lock, ScopedLock, TemplatedScopedLock, TemporaryScopedLock.

Constructor & Destructor Documentation

◆ OptionalScopedLock() [1/3]

Ocean::OptionalScopedLock::OptionalScopedLock ( Lock lock)
inlineexplicit

Creates a new optional scoped lock object by a given lock object.

Parameters
lockOptional lock object used for locking, otherwise nullptr

◆ OptionalScopedLock() [2/3]

Ocean::OptionalScopedLock::OptionalScopedLock ( Lock lock,
const bool  apply 
)
inline

Creates a new optional scoped lock object by a given lock object and a boolean statement whether the lock is invoked or not.

Parameters
lockThe lock object used for locking
applyTrue, to invoke the lock; False, to avoid the locking

◆ ~OptionalScopedLock()

Ocean::OptionalScopedLock::~OptionalScopedLock ( )
inline

Destructs an optional scoped lock and unlocks the internal lock object if defined.

◆ OptionalScopedLock() [3/3]

Ocean::OptionalScopedLock::OptionalScopedLock ( const OptionalScopedLock object)
inlineprotecteddelete

Disabled accessible copy operator.

Parameters
objectThe object to copy

Member Function Documentation

◆ lock()

Lock * Ocean::OptionalScopedLock::lock ( ) const
inline

Returns the lock object which (if existing) is locked during the existence of this scoped lock object.

Returns
The associated lock object, nullptr if no lock object was provided when this object was created

◆ operator=()

OptionalScopedLock& Ocean::OptionalScopedLock::operator= ( const OptionalScopedLock object)
inlineprotecteddelete

Disabled accessible assigns operator.

Parameters
objectThe right object
Returns
Reference to this object

Field Documentation

◆ lock_

Lock* Ocean::OptionalScopedLock::lock_ = nullptr
protected

Lock object which is locked during the existence of this scoped lock object.


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