Atomic lock allowing only one process to acquire it. Implemented using MPI3 RMA. More...
#include <util.h>
Atomic lock allowing only one process to acquire it. Implemented using MPI3 RMA.
Classes | |
struct | Proxy |
Proxy that locks on creation and unlocks on destruction. Useful for locking a scope. More... | |
Public Member Functions | |
LockMPI3 (MPI_Comm comm) | |
Create the lock without acquiring it. This is collective and must be called by all processes in the communicator. More... | |
~LockMPI3 () | |
Release the lock and destroy it. This is collective and must be called by all processes in the communicator. More... | |
LockMPI3 ()=delete | |
LockMPI3 (const LockMPI3 &)=delete | |
LockMPI3 & | operator= (const LockMPI3 &)=delete |
void | lock () |
Acquire exclusive lock. More... | |
void | unlock () |
Release the lock. More... | |
std::shared_ptr< Proxy > | scope () |
Protected Attributes | |
MPI_Comm | m_comm = MPI_COMM_NULL |
MPI communicator. More... | |
MPI_Win | m_win = MPI_WIN_NULL |
empty window handle More... | |
bool | m_locked = false |
whether lock is active More... | |
std::weak_ptr< Proxy > | m_proxy |
Keep track of proxy object so that if lock is deleted, the proxy does not try to unlock. More... | |
molpro::linalg::array::util::LockMPI3::LockMPI3 | ( | MPI_Comm | comm | ) |
Create the lock without acquiring it. This is collective and must be called by all processes in the communicator.
molpro::linalg::array::util::LockMPI3::~LockMPI3 | ( | ) |
Release the lock and destroy it. This is collective and must be called by all processes in the communicator.
|
delete |
|
delete |
void molpro::linalg::array::util::LockMPI3::lock | ( | ) |
Acquire exclusive lock.
std::shared_ptr< LockMPI3::Proxy > molpro::linalg::array::util::LockMPI3::scope | ( | ) |
Return a proxy object that acquires the lock on creation and releases it on destruction. Useful for locking a scope.
void molpro::linalg::array::util::LockMPI3::unlock | ( | ) |
Release the lock.
|
protected |
MPI communicator.
|
protected |
whether lock is active
|
protected |
Keep track of proxy object so that if lock is deleted, the proxy does not try to unlock.
|
protected |
empty window handle