preCICE v3.1.2
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Private Types | Private Attributes | List of all members
precice::utils::MultiLock< Key > Class Template Reference

Class handling multiple locks allowing global lock and unlock operations. More...

#include <MultiLock.hpp>

Collaboration diagram for precice::utils::MultiLock< Key >:
[legend]

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.
 

Detailed Description

template<typename Key>
class precice::utils::MultiLock< Key >

Class handling multiple locks allowing global lock and unlock operations.

Definition at line 27 of file MultiLock.hpp.

Member Typedef Documentation

◆ key_type

template<typename Key >
using precice::utils::MultiLock< Key >::key_type = Key

The type of the key.

Definition at line 30 of file MultiLock.hpp.

◆ map_type

template<typename Key >
using precice::utils::MultiLock< Key >::map_type = typename std::map<Key, bool, std::less<>>
private

Definition at line 156 of file MultiLock.hpp.

◆ size_type

template<typename Key >
using precice::utils::MultiLock< Key >::size_type = std::size_t

The size type.

Definition at line 33 of file MultiLock.hpp.

Member Function Documentation

◆ add()

template<typename Key >
void precice::utils::MultiLock< Key >::add ( Key name,
bool state )
inline

Adds a lock with a given state.

Adding an already existent lock does nothing.

Parameters
[in]namethe name of the lock
[in]statethe initial state of the lock

Definition at line 42 of file MultiLock.hpp.

◆ check()

template<typename Key >
template<typename K >
bool precice::utils::MultiLock< Key >::check ( const K & name) const
inline

Checks the status of a lock.

Parameters
[in]namethe name of the lock to check
Returns
whether the lock is locked

Definition at line 106 of file MultiLock.hpp.

◆ checkAll()

template<typename Key >
bool precice::utils::MultiLock< Key >::checkAll ( ) const
inlinenoexcept

Checks whether all locks are locked.

Definition at line 117 of file MultiLock.hpp.

Here is the call graph for this function:

◆ clear()

template<typename Key >
void precice::utils::MultiLock< Key >::clear ( )
inlinenoexcept

Removes all known locks.

Definition at line 94 of file MultiLock.hpp.

◆ contains()

template<typename Key >
template<typename K >
bool precice::utils::MultiLock< Key >::contains ( const K & name) const
inlinenoexcept

Checks whether a lock is known.

Parameters
[in]namethe name to check
Returns
whether the name is a known lock

Definition at line 132 of file MultiLock.hpp.

◆ countLocked()

template<typename Key >
size_t precice::utils::MultiLock< Key >::countLocked ( ) const
inline

Returns the count of locked locks.

Definition at line 144 of file MultiLock.hpp.

Here is the call graph for this function:

◆ countUnlocked()

template<typename Key >
size_t precice::utils::MultiLock< Key >::countUnlocked ( ) const
inline

Returns the count of unlocked locks.

Definition at line 150 of file MultiLock.hpp.

Here is the call graph for this function:

◆ lock()

template<typename Key >
template<typename K >
void precice::utils::MultiLock< Key >::lock ( const K & name)
inline

Locks a given lock.

Parameters
[in]namethe name of to lock

Definition at line 52 of file MultiLock.hpp.

◆ lockAll()

template<typename Key >
void precice::utils::MultiLock< Key >::lockAll ( )
inlinenoexcept

Locks all known locks.

Definition at line 63 of file MultiLock.hpp.

◆ size()

template<typename Key >
size_type precice::utils::MultiLock< Key >::size ( ) const
inlinenoexcept

Returns the total count of locks.

Definition at line 138 of file MultiLock.hpp.

◆ unlock()

template<typename Key >
template<typename K >
void precice::utils::MultiLock< Key >::unlock ( const K & name)
inline

Unlocks a given lock.

Parameters
[in]namethe name of to unlock

Definition at line 75 of file MultiLock.hpp.

◆ unlockAll()

template<typename Key >
void precice::utils::MultiLock< Key >::unlockAll ( )
inlinenoexcept

Unlocks all known locks.

Definition at line 86 of file MultiLock.hpp.

Member Data Documentation

◆ _locks

template<typename Key >
map_type precice::utils::MultiLock< Key >::_locks
private

The map that keeps track of the locks and their state.

Definition at line 159 of file MultiLock.hpp.


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