Advanced Multi-Physics (AMP)
On-Line Documentation
Mutex.h
Go to the documentation of this file.
1#ifndef included_AMP_Mutex
2#define included_AMP_Mutex
3
4#include <atomic>
5#include <memory>
6#include <mutex>
7
8
9namespace AMP {
10
11
12class AMP_MPI; // Forward decleration of AMP_MPI
13
14
24class Mutex
25{
26public:
32 explicit Mutex( bool recursive );
34 ~Mutex() = default;
36 Mutex( const Mutex & ) = delete;
38 Mutex &operator=( const Mutex & ) = delete;
40 void lock();
42 void unlock();
44 bool tryLock();
46 bool ownLock() const;
47
48private:
49 bool d_recursive; // Is the lock recursive (this attribute cannot be changed)
50 volatile int d_count; // lock_count
51 volatile int d_id; // thread_id
52 std::mutex d_mutex; // internal mutex
53};
54
55
63void lock_MPI_Mutex( AMP::Mutex &mutex, const AMP::AMP_MPI &comm );
64
65
66} // namespace AMP
67
68#endif
Provides C++ wrapper around MPI routines.
Definition AMP_MPI.h:63
Functions for locking/unlocking a mutex.
Definition Mutex.h:25
Mutex(const Mutex &)=delete
Copy constructor.
bool tryLock()
Try to lock the mutex and return true if successful.
Mutex & operator=(const Mutex &)=delete
Assignment operator.
void unlock()
Unlock the mutex.
bool d_recursive
Definition Mutex.h:49
void lock()
Lock the mutex.
std::mutex d_mutex
Definition Mutex.h:52
Mutex()
Empty constructor (equivalent to Mutex(false) )
~Mutex()=default
Destructor.
volatile int d_id
Definition Mutex.h:51
bool ownLock() const
Return true if we already own the lock.
volatile int d_count
Definition Mutex.h:50
Mutex(bool recursive)
void lock_MPI_Mutex(AMP::Mutex &mutex, const AMP::AMP_MPI &comm)
Function to sycronize locking a mutex across a MPI communicator.



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:41.
Comments on this page