SG++-Doxygen-Documentation
sgpp::optimization::ScopedLock Class Reference

Wrapper around MutexType which locks and unlocks upon construction/destruction. More...

#include <ScopedLock.hpp>

Public Member Functions

void lockAgain ()
 Re-locks the MutexType object, if unlocked. More...
 
 ScopedLock (MutexType &m)
 Constructor, locks the MutexType object. More...
 
void unlock ()
 Unlocks the MutexType object, if locked. More...
 
 ~ScopedLock ()
 Destructor, unlocks the MutexType object. More...
 

Protected Attributes

bool locked
 whether the MutexType object is locked or not More...
 
MutexType & mut
 underlying MutexType object More...
 

Detailed Description

Wrapper around MutexType which locks and unlocks upon construction/destruction.

Adopted from http://bisqwit.iki.fi/story/howto/openmp/#Locks.

Constructor & Destructor Documentation

◆ ScopedLock()

sgpp::optimization::ScopedLock::ScopedLock ( MutexType &  m)
inlineexplicit

Constructor, locks the MutexType object.

Parameters
mMutexType object to be wrapped

References sgpp::optimization::MutexType::lock(), and mut.

◆ ~ScopedLock()

sgpp::optimization::ScopedLock::~ScopedLock ( )
inline

Destructor, unlocks the MutexType object.

References unlock().

Member Function Documentation

◆ lockAgain()

void sgpp::optimization::ScopedLock::lockAgain ( )
inline

Re-locks the MutexType object, if unlocked.

References sgpp::optimization::MutexType::lock(), locked, and mut.

◆ unlock()

void sgpp::optimization::ScopedLock::unlock ( )
inline

Unlocks the MutexType object, if locked.

References locked, mut, and sgpp::optimization::MutexType::unlock().

Referenced by ~ScopedLock().

Member Data Documentation

◆ locked

bool sgpp::optimization::ScopedLock::locked
protected

whether the MutexType object is locked or not

Referenced by lockAgain(), and unlock().

◆ mut

MutexType& sgpp::optimization::ScopedLock::mut
protected

underlying MutexType object

Referenced by lockAgain(), ScopedLock(), and unlock().


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