Fawkes API  Fawkes Development Version
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
fawkes::LockHashMap< KeyType, ValueType, HashFunction, EqualKey > Class Template Reference

Hash map with a lock. More...

#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 47 of file lock_hashmap.h.

Constructor & Destructor Documentation

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

Constructor.

Definition at line 82 of file lock_hashmap.h.

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 92 of file lock_hashmap.h.

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

Destructor.

Definition at line 105 of file lock_hashmap.h.

Member Function Documentation

template<class KeyType , class ValueType , class HashFunction , class EqualKey >
void fawkes::LockHashMap< KeyType, ValueType, HashFunction, EqualKey >::lock ( ) const
template<typename KeyType , typename ValueType , class HashFunction , typename EqualKey >
RefPtr< Mutex > fawkes::LockHashMap< KeyType, ValueType, HashFunction, EqualKey >::mutex ( ) const

Get access to the internal mutex.

Can be used with MutexLocker.

Returns
internal mutex

Definition at line 145 of file lock_hashmap.h.

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 159 of file lock_hashmap.h.

References fawkes::LockHashMap< KeyType, ValueType, HashFunction, EqualKey >::lock(), and fawkes::LockHashMap< KeyType, ValueType, HashFunction, EqualKey >::unlock().

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

Try to lock map.

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

Definition at line 124 of file lock_hashmap.h.

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

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