Peano
Loading...
Searching...
No Matches
tarch::multicore::Lock Class Reference

Create a lock around a boolean semaphore region. More...

#include <Lock.h>

Collaboration diagram for tarch::multicore::Lock:

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
 

Detailed Description

Create a lock around a boolean semaphore region.

See also
tarch::multicore::BooleanSemaphore

Definition at line 19 of file Lock.h.

Constructor & Destructor Documentation

◆ Lock()

tarch::multicore::Lock::Lock ( tarch::multicore::BooleanSemaphore & semaphore,
bool aquireLockImmediately = true,
bool freeLockInDestructor = true )

Create lock around semaphore.

Parameters
aquireLockImmediatelyIf 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.
freeLockInDestructorIf 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().

Here is the call graph for this function:

◆ ~Lock()

tarch::multicore::Lock::~Lock ( )

Definition at line 16 of file Lock.cpp.

Member Function Documentation

◆ free()

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().

Here is the caller graph for this function:

◆ lock()

◆ tryLock()

bool tarch::multicore::Lock::tryLock ( )

Definition at line 23 of file Lock.cpp.

References assertion.

Referenced by swift2::TaskEnumerator::lockResources().

Here is the caller graph for this function:

Field Documentation

◆ _freeLockInDestructor

const bool tarch::multicore::Lock::_freeLockInDestructor
private

Definition at line 23 of file Lock.h.

◆ _lockIsAquired

bool tarch::multicore::Lock::_lockIsAquired
private

Definition at line 22 of file Lock.h.

◆ _semaphore

BooleanSemaphore& tarch::multicore::Lock::_semaphore
private

Definition at line 21 of file Lock.h.


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