![]() |
Peano
|
Create a lock around a boolean semaphore region. More...
#include <Lock.h>
Public Member Functions | |
Lock (tarch::multicore::BooleanSemaphore &semaphore, bool aquireLockImmediately=true, bool freeLockInDestructor=true) | |
Create lock around semaphore. | |
~Lock () | |
void | lock () |
void | free () |
Free the lock. | |
bool | tryLock () |
Private Attributes | |
BooleanSemaphore & | _semaphore |
bool | _lockIsAquired |
const bool | _freeLockInDestructor |
Create a lock around a boolean semaphore region.
tarch::multicore::Lock::Lock | ( | tarch::multicore::BooleanSemaphore & | semaphore, |
bool | aquireLockImmediately = true, | ||
bool | freeLockInDestructor = true ) |
Create lock around semaphore.
aquireLockImmediately | If set, the constructor locks the semaphore immediately when you construct the object. If the parameter is overwritten with false, you have to use the lock's lock() operation. |
freeLockInDestructor | If set and if the lock has locked the semaphore, it will free it in the destructor unless you have manually unlocked it before. This parameter should be altered very carefully. |
Definition at line 6 of file Lock.cpp.
References lock().
void tarch::multicore::Lock::free | ( | ) |
Free the lock.
There is an assertion here that checks if you have acquired the lock before. When people use the locks to wrap around the semaphore and to alter it manually, i.e. when they disable the automatic lock management in the constructor by unsetting freeLockInDestructor, then these checks are not valid anymore.
Definition at line 37 of file Lock.cpp.
References assertion.
Referenced by toolbox::blockstructured::GlobalDatabase::addGlobalSnapshot(), toolbox::blockstructured::GlobalDatabase::addGlobalSnapshot(), toolbox::particles::TrajectoryDatabase::addParticleSnapshot(), toolbox::particles::TrajectoryDatabase::addParticleSnapshot(), exahype2::EnclaveBookkeeping::finishedTask(), toolbox::blockstructured::interpolateHaloLayer_AoS_linear_with_constant_extrapolation(), toolbox::blockstructured::interpolateHaloLayer_AoS_linear_with_constant_extrapolation_and_linear_normal_interpolation(), toolbox::blockstructured::interpolateHaloLayer_AoS_linear_with_linear_extrapolation(), toolbox::blockstructured::interpolateHaloLayer_AoS_linear_with_linear_extrapolation_and_linear_normal_interpolation(), toolbox::blockstructured::interpolateHaloLayer_AoS_piecewise_constant(), swift2::TaskEnumerator::lockResources(), toolbox::loadbalancing::metrics::CustomCellWeight::logCellWeight(), tarch::multicore::taskfusion::ProcessReadyTask::processTasks(), tarch::multicore::spawnAndWait(), tarch::multicore::taskfusion::translateFusableTaskIntoTaskSequence(), tarch::multicore::taskfusion::ProcessReadyTask::tryToProcessOneTask(), swift2::TaskEnumerator::unlockResources(), and exahype2::EnclaveBookkeeping::waitForTaskToTerminateAndReturnResult().
void tarch::multicore::Lock::lock | ( | ) |
Definition at line 30 of file Lock.cpp.
References assertion.
Referenced by toolbox::blockstructured::GlobalDatabase::clear(), toolbox::particles::TrajectoryDatabase::clear(), toolbox::particles::TrajectoryDatabase::clearHistory(), Lock(), tarch::multicore::taskfusion::ProcessReadyTask::processTasks(), and tarch::multicore::spawnAndWait().
bool tarch::multicore::Lock::tryLock | ( | ) |
Definition at line 23 of file Lock.cpp.
References assertion.
Referenced by swift2::TaskEnumerator::lockResources().
|
private |
|
private |