Advanced Multi-Physics (AMP)
On-Line Documentation
Public Member Functions | Private Attributes | List of all members
AMP::Mutex Class Reference

Functions for locking/unlocking a mutex. More...

#include <Mutex.h>

Public Member Functions

void lock ()
 Lock the mutex.
 
 Mutex ()
 Empty constructor (equivalent to Mutex(false) )
 
 Mutex (bool recursive)
 
 Mutex (const Mutex &)=delete
 Copy constructor.
 
Mutexoperator= (const Mutex &)=delete
 Assignment operator.
 
bool ownLock () const
 Return true if we already own the lock.
 
bool tryLock ()
 Try to lock the mutex and return true if successful.
 
void unlock ()
 Unlock the mutex.
 
 ~Mutex ()=default
 Destructor.
 

Private Attributes

volatile int d_count
 
volatile int d_id
 
std::mutex d_mutex
 
bool d_recursive
 

Detailed Description

Functions for locking/unlocking a mutex.

This class provides basic routines for creating, locking, and unlocking a mutex
The lock may be recursive, meaning that the same thread may lock and unlock the lock multiple times before releasing it. In this case unlock must be called the same number of times before another thread may lock the mutex.

Definition at line 24 of file Mutex.h.

Constructor & Destructor Documentation

◆ Mutex() [1/3]

AMP::Mutex::Mutex ( )

Empty constructor (equivalent to Mutex(false) )

◆ Mutex() [2/3]

AMP::Mutex::Mutex ( bool  recursive)
explicit

Default constructor

Parameters
recursiveIf set to true a thread may repeated lock a mutex. If set to false an attept to repeatedly lock will throw an error.

◆ ~Mutex()

AMP::Mutex::~Mutex ( )
default

Destructor.

◆ Mutex() [3/3]

AMP::Mutex::Mutex ( const Mutex )
delete

Copy constructor.

Member Function Documentation

◆ lock()

void AMP::Mutex::lock ( )

Lock the mutex.

◆ operator=()

Mutex & AMP::Mutex::operator= ( const Mutex )
delete

Assignment operator.

◆ ownLock()

bool AMP::Mutex::ownLock ( ) const

Return true if we already own the lock.

◆ tryLock()

bool AMP::Mutex::tryLock ( )

Try to lock the mutex and return true if successful.

◆ unlock()

void AMP::Mutex::unlock ( )

Unlock the mutex.

Member Data Documentation

◆ d_count

volatile int AMP::Mutex::d_count
private

Definition at line 50 of file Mutex.h.

◆ d_id

volatile int AMP::Mutex::d_id
private

Definition at line 51 of file Mutex.h.

◆ d_mutex

std::mutex AMP::Mutex::d_mutex
private

Definition at line 52 of file Mutex.h.

◆ d_recursive

bool AMP::Mutex::d_recursive
private

Definition at line 49 of file Mutex.h.


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



Advanced Multi-Physics (AMP)
Oak Ridge National Laboratory
Idaho National Laboratory
Los Alamos National Laboratory
This page automatically produced from the
source code by doxygen
Last updated: Tue Mar 10 2026 13:06:42.
Comments on this page