Fawkes API  Fawkes Development Version
fawkes::LockMap< KeyType, ValueType, LessKey > Class Template Reference

Map with a lock. More...

#include <>>

Inheritance diagram for fawkes::LockMap< KeyType, ValueType, LessKey >:

Public Member Functions

 LockMap ()
 Constructor. More...
 
 LockMap (const LockMap< KeyType, ValueType, LessKey > &lm)
 Copy constructor. More...
 
virtual ~LockMap ()
 Destructor. More...
 
void lock () const
 Lock list. More...
 
bool try_lock () const
 Try to lock list. More...
 
void unlock () const
 Unlock list. More...
 
RefPtr< Mutexmutex () const
 Get access to the internal mutex. More...
 
void erase_locked (const KeyType &key)
 Remove item with lock. More...
 
LockMap< KeyType, ValueType, LessKey > & operator= (const LockMap< KeyType, ValueType, LessKey > &ll)
 Copy values from another LockMap. More...
 
LockMap< KeyType, ValueType, LessKey > & operator= (const std::map< KeyType, ValueType, LessKey > &l)
 Copy values from a standard map. More...
 

Detailed Description

template<typename KeyType, typename ValueType, typename LessKey = std::less<KeyType>>
class fawkes::LockMap< KeyType, ValueType, LessKey >

Map with a lock.

This class provides a 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 35 of file lock_map.h.

Constructor & Destructor Documentation

◆ LockMap() [1/2]

template<typename KeyType , typename ValueType , typename LessKey >
fawkes::LockMap< KeyType, ValueType, LessKey >::LockMap

Constructor.

Definition at line 69 of file lock_map.h.

◆ LockMap() [2/2]

template<typename KeyType , typename ValueType , typename LessKey >
fawkes::LockMap< KeyType, ValueType, LessKey >::LockMap ( const LockMap< KeyType, ValueType, LessKey > &  lm)

Copy constructor.

Parameters
lmLockMap to copy

Definition at line 77 of file lock_map.h.

◆ ~LockMap()

template<typename KeyType , typename ValueType , typename LessKey >
fawkes::LockMap< KeyType, ValueType, LessKey >::~LockMap
virtual

Destructor.

Definition at line 84 of file lock_map.h.

Member Function Documentation

◆ erase_locked()

template<typename KeyType , typename ValueType , typename LessKey >
void fawkes::LockMap< KeyType, ValueType, LessKey >::erase_locked ( const KeyType &  key)

Remove item with lock.

The map is automatically locked and unlocked during the removal.

Parameters
keykey of the value to erase

Definition at line 120 of file lock_map.h.

Referenced by fawkes::PluginManager::load(), and fawkes::PluginManager::unload().

◆ lock()

◆ mutex()

template<typename KeyType , typename ValueType , typename LessKey >
RefPtr< Mutex > fawkes::LockMap< KeyType, ValueType, LessKey >::mutex

Get access to the internal mutex.

Can be used with MutexLocker.

Returns
internal mutex

Definition at line 133 of file lock_map.h.

Referenced by FvBaseThread::acquire_camctrl(), MetricsThread::init(), and fawkes::PluginManager::load().

◆ operator=() [1/2]

template<typename KeyType , typename ValueType , typename LessKey >
LockMap< KeyType, ValueType, LessKey > & fawkes::LockMap< KeyType, ValueType, LessKey >::operator= ( const LockMap< KeyType, ValueType, LessKey > &  ll)

Copy values from another LockMap.

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

Parameters
llmap to copy
Returns
reference to this instance

Definition at line 146 of file lock_map.h.

References fawkes::LockMap< KeyType, ValueType, LessKey >::lock(), and fawkes::LockMap< KeyType, ValueType, LessKey >::unlock().

◆ operator=() [2/2]

template<typename KeyType , typename ValueType , typename LessKey >
LockMap< KeyType, ValueType, LessKey > & fawkes::LockMap< KeyType, ValueType, LessKey >::operator= ( const std::map< KeyType, ValueType, LessKey > &  l)

Copy values from a standard map.

Copies the values one by one. This instance is locked during the copying and cleared.

Parameters
lmap to copy
Returns
reference to this instance

Definition at line 169 of file lock_map.h.

◆ try_lock()

template<typename KeyType , typename ValueType , typename LessKey >
bool fawkes::LockMap< KeyType, ValueType, LessKey >::try_lock

Try to lock list.

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

Definition at line 101 of file lock_map.h.

◆ unlock()


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