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

Hash set with a lock. More...

#include <core/utils/lock_hashset.h>

Inheritance diagram for fawkes::LockHashSet< KeyType, HashFunction, EqualKey >:

Public Member Functions

 LockHashSet ()
 Constructor. More...
 
 LockHashSet (const LockHashSet< KeyType, HashFunction, EqualKey > &lh)
 Copy constructor. More...
 
virtual ~LockHashSet ()
 Destructor. More...
 
void lock () const
 Lock set. More...
 
bool try_lock () const
 Try to lock set. More...
 
void unlock () const
 Unlock set. More...
 
RefPtr< Mutexmutex () const
 Get access to the internal mutex. More...
 
void insert_locked (const KeyType &x)
 Insert element to hash set with lock protection. More...
 
LockHashSet< KeyType, HashFunction, EqualKey > & operator= (const LockHashSet< KeyType, HashFunction, EqualKey > &ll)
 Copy values from another LockHashSet. More...
 

Detailed Description

template<class KeyType, class HashFunction = __gnu_cxx::hash<KeyType>, class EqualKey = std::equal_to<KeyType>>
class fawkes::LockHashSet< KeyType, HashFunction, EqualKey >

Hash set with a lock.

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

See also
Mutex
Author
Tim Niemueller

Definition at line 54 of file lock_hashset.h.

Constructor & Destructor Documentation

◆ LockHashSet() [1/2]

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

Constructor.

Definition at line 91 of file lock_hashset.h.

◆ LockHashSet() [2/2]

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

Copy constructor.

Parameters
lhLockHashSet to copy

Definition at line 100 of file lock_hashset.h.

◆ ~LockHashSet()

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

Destructor.

Definition at line 114 of file lock_hashset.h.

Member Function Documentation

◆ insert_locked()

template<class KeyType, class HashFunction , class EqualKey >
void fawkes::LockHashSet< KeyType, HashFunction, EqualKey >::insert_locked ( const KeyType &  x)

Insert element to hash set with lock protection.

Parameters
xelement to add

Definition at line 152 of file lock_hashset.h.

◆ lock()

template<class KeyType , class HashFunction , class EqualKey >
void fawkes::LockHashSet< KeyType, HashFunction, EqualKey >::lock ( ) const

◆ mutex()

template<typename KeyType , class HashFunction , class EqualKey >
RefPtr< Mutex > fawkes::LockHashSet< KeyType, HashFunction, EqualKey >::mutex ( ) const

Get access to the internal mutex.

Can be used with MutexLocker.

Returns
internal mutex

Definition at line 166 of file lock_hashset.h.

◆ operator=()

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

Copy values from another LockHashSet.

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

Parameters
lllock hash set to copy
Returns
reference to this instance

Definition at line 179 of file lock_hashset.h.

◆ try_lock()

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

Try to lock set.

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

Definition at line 132 of file lock_hashset.h.

Referenced by fawkes::LockHashSet< std::string >::try_lock().

◆ unlock()

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

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