SG++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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...
 
MutexTypemut
 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

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.

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

Destructor, unlocks the MutexType object.

References unlock().

Member Function Documentation

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

Re-locks the MutexType object, if unlocked.

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

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

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

whether the MutexType object is locked or not

Referenced by lockAgain(), and unlock().

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: