Fawkes API  Fawkes Development Version
fawkes::LockHashMap< KeyType, ValueType, HashFunction, EqualKey > Class Template Reference

#include <core/utils/lock_hashmap.h>

Inheritance diagram for fawkes::LockHashMap< KeyType, ValueType, HashFunction, EqualKey >:

Public Member Functions

 LockHashMap ()
 Constructor. More...
 
 LockHashMap (const LockHashMap< KeyType, ValueType, HashFunction, EqualKey > &lh)
 Copy constructor. More...
 
virtual ~LockHashMap ()
 Destructor. More...
 
void lock () const
 Lock map. More...
 
bool try_lock () const
 Try to lock map. More...
 
void unlock () const
 Unlock map. More...
 
RefPtr< Mutexmutex () const
 Get access to the internal mutex. More...
 
LockHashMap< KeyType, ValueType, HashFunction, EqualKey > & operator= (const LockHashMap< KeyType, ValueType, HashFunction, EqualKey > &ll)
 Copy values from another LockHashMap. More...
 

Detailed Description

template<class KeyType, class ValueType, class HashFunction = gnu_cxx_::hash<KeyType>, class EqualKey = std::equal_to<KeyType>>
class fawkes::LockHashMap< KeyType, ValueType, HashFunction, EqualKey >

Hash map with a lock. This class provides a hash map that has an intrinsic lock. The lock can be applied with the regular locking methods.

See also
Mutex
Author
Tim Niemueller

Definition at line 61 of file lock_hashmap.h.

Constructor & Destructor Documentation

◆ LockHashMap() [1/2]

template<class KeyType , class ValueType , class HashFunction , class EqualKey >
fawkes::LockHashMap< KeyType, ValueType, HashFunction, EqualKey >::LockHashMap

Constructor.

Definition at line 93 of file lock_hashmap.h.

◆ LockHashMap() [2/2]

template<class KeyType , class ValueType , class HashFunction , class EqualKey >
fawkes::LockHashMap< KeyType, ValueType, HashFunction, EqualKey >::LockHashMap ( const LockHashMap< KeyType, ValueType, HashFunction, EqualKey > &  lh)

Copy constructor.

Parameters
lhLockHashMap to copy

Definition at line 101 of file lock_hashmap.h.

◆ ~LockHashMap()

template<class KeyType , class ValueType , class HashFunction , class EqualKey >
fawkes::LockHashMap< KeyType, ValueType, HashFunction, EqualKey >::~LockHashMap
virtual

Destructor.

Definition at line 117 of file lock_hashmap.h.

Member Function Documentation

◆ lock()

template<class KeyType , class ValueType , class HashFunction , class EqualKey >
void fawkes::LockHashMap< KeyType, ValueType, HashFunction, EqualKey >::lock

Lock map.

Definition at line 124 of file lock_hashmap.h.

Referenced by fawkes::NetworkNameResolver::cache_timeout().

◆ mutex()

template<typename KeyType , typename ValueType , class HashFunction , typename EqualKey >
RefPtr< Mutex > fawkes::LockHashMap< KeyType, ValueType, HashFunction, EqualKey >::mutex

Get access to the internal mutex.

Can be used with MutexLocker.

Returns
internal mutex

Definition at line 153 of file lock_hashmap.h.

◆ operator=()

template<typename KeyType , typename ValueType , class HashFunction , typename EqualKey >
LockHashMap< KeyType, ValueType, HashFunction, EqualKey > & fawkes::LockHashMap< KeyType, ValueType, HashFunction, EqualKey >::operator= ( const LockHashMap< KeyType, ValueType, HashFunction, EqualKey > &  ll)

Copy values from another LockHashMap.

Copies the values one by one. Both instances are locked during the copying and this instance is cleared before copying.

Parameters
llhash map to copy
Returns
reference to this instance

Definition at line 167 of file lock_hashmap.h.

◆ try_lock()

template<class KeyType , class ValueType , class HashFunction , class EqualKey >
bool fawkes::LockHashMap< KeyType, ValueType, HashFunction, EqualKey >::try_lock

Try to lock map.

Returns
true, if the lock has been aquired, false otherwise.

Definition at line 134 of file lock_hashmap.h.

◆ unlock()

template<class KeyType , class ValueType , class HashFunction , class EqualKey >
void fawkes::LockHashMap< KeyType, ValueType, HashFunction, EqualKey >::unlock

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