preCICE v3.2.0
|
Class handling multiple locks allowing global lock and unlock operations. More...
#include <MultiLock.hpp>
Public Types | |
using | key_type = Key |
The type of the key. | |
using | size_type = std::size_t |
The size type. | |
Public Member Functions | |
void | add (Key name, bool state) |
Adds a lock with a given state. | |
template<typename K > | |
void | lock (const K &name) |
Locks a given lock. | |
void | lockAll () noexcept |
Locks all known locks. | |
template<typename K > | |
void | unlock (const K &name) |
Unlocks a given lock. | |
void | unlockAll () noexcept |
Unlocks all known locks. | |
void | clear () noexcept |
Removes all known locks. | |
template<typename K > | |
bool | check (const K &name) const |
Checks the status of a lock. | |
bool | checkAll () const noexcept |
Checks whether all locks are locked. | |
template<typename K > | |
bool | contains (const K &name) const noexcept |
Checks whether a lock is known. | |
size_type | size () const noexcept |
Returns the total count of locks. | |
size_t | countLocked () const |
Returns the count of locked locks. | |
size_t | countUnlocked () const |
Returns the count of unlocked locks. | |
Private Types | |
using | map_type = typename std::map<Key, bool, std::less<>> |
Private Attributes | |
map_type | _locks |
The map that keeps track of the locks and their state. | |
Class handling multiple locks allowing global lock and unlock operations.
Definition at line 26 of file MultiLock.hpp.
using precice::utils::MultiLock< Key >::key_type = Key |
The type of the key.
Definition at line 29 of file MultiLock.hpp.
|
private |
Definition at line 155 of file MultiLock.hpp.
using precice::utils::MultiLock< Key >::size_type = std::size_t |
The size type.
Definition at line 32 of file MultiLock.hpp.
|
inline |
Adds a lock with a given state.
Adding an already existent lock does nothing.
[in] | name | the name of the lock |
[in] | state | the initial state of the lock |
Definition at line 41 of file MultiLock.hpp.
|
inline |
Checks the status of a lock.
[in] | name | the name of the lock to check |
Definition at line 105 of file MultiLock.hpp.
|
inlinenoexcept |
Checks whether all locks are locked.
Definition at line 116 of file MultiLock.hpp.
|
inlinenoexcept |
Removes all known locks.
Definition at line 93 of file MultiLock.hpp.
|
inlinenoexcept |
Checks whether a lock is known.
[in] | name | the name to check |
Definition at line 131 of file MultiLock.hpp.
|
inline |
Returns the count of locked locks.
Definition at line 143 of file MultiLock.hpp.
|
inline |
Returns the count of unlocked locks.
Definition at line 149 of file MultiLock.hpp.
|
inline |
Locks a given lock.
[in] | name | the name of to lock |
Definition at line 51 of file MultiLock.hpp.
|
inlinenoexcept |
Locks all known locks.
Definition at line 62 of file MultiLock.hpp.
|
inlinenoexcept |
Returns the total count of locks.
Definition at line 137 of file MultiLock.hpp.
|
inline |
Unlocks a given lock.
[in] | name | the name of to unlock |
Definition at line 74 of file MultiLock.hpp.
|
inlinenoexcept |
Unlocks all known locks.
Definition at line 85 of file MultiLock.hpp.
|
private |
The map that keeps track of the locks and their state.
Definition at line 158 of file MultiLock.hpp.