18 const char *
what() const noexcept
override
20 return "The multilock does not contain the requested lock!";
25template <
typename Key>
41 void add(Key name,
bool state)
43 _locks.emplace(std::move(name), state);
53 auto iter =
_locks.find(name);
54 if (iter ==
_locks.end()) {
76 auto iter =
_locks.find(name);
77 if (iter ==
_locks.end()) {
104 template <
typename K>
107 auto iter =
_locks.find(name);
108 if (iter ==
_locks.end()) {
118 using KL =
typename decltype(
_locks)::value_type;
130 template <
typename K>
151 return std::count_if(
_locks.begin(),
_locks.end(), [](
typename map_type::value_type
const &kv) { return not kv.second; });
LockNotFoundException()=default
const char * what() const noexcept override
Class handling multiple locks allowing global lock and unlock operations.
size_t countLocked() const
Returns the count of locked locks.
bool check(const K &name) const
Checks the status of a lock.
Key key_type
The type of the key.
size_t countUnlocked() const
Returns the count of unlocked locks.
void add(Key name, bool state)
Adds a lock with a given state.
void lock(const K &name)
Locks a given lock.
void clear() noexcept
Removes all known locks.
void lockAll() noexcept
Locks all known locks.
std::size_t size_type
The size type.
void unlockAll() noexcept
Unlocks all known locks.
bool checkAll() const noexcept
Checks whether all locks are locked.
typename std::map< Key, bool, std::less<> > map_type
size_type size() const noexcept
Returns the total count of locks.
map_type _locks
The map that keeps track of the locks and their state.
bool contains(const K &name) const noexcept
Checks whether a lock is known.
void unlock(const K &name)
Unlocks a given lock.
contains precice-related utilities.