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

Hash map with a lock. More...

#include <core/utils/rwlock_map.h>

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

Public Member Functions

 RWLockMap ()
 Constructor. More...
 
 RWLockMap (const RWLockMap< KeyType, ValueType, LessKey > &lm)
 Copy constructor. More...
 
virtual ~RWLockMap ()
 Destructor. More...
 
void lock_for_read ()
 Lock list for reading. More...
 
void lock_for_write ()
 Lock list for writing. More...
 
bool try_lock_for_read ()
 Try to lock list for reading. More...
 
bool try_lock_for_write ()
 Try to lock list for writing. More...
 
void unlock ()
 Unlock list. More...
 
RefPtr< ReadWriteLockrwlock () const
 Get access to the internal rwlock. More...
 
void erase_locked (const KeyType &key)
 Remove item with lock. More...
 

Detailed Description

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

Hash map with a lock.

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

See also
ReadWriteLock
Author
Tim Niemueller

Definition at line 37 of file rwlock_map.h.

Constructor & Destructor Documentation

◆ RWLockMap() [1/2]

template<typename KeyType , typename ValueType , typename LessKey >
fawkes::RWLockMap< KeyType, ValueType, LessKey >::RWLockMap ( )

Constructor.

Definition at line 72 of file rwlock_map.h.

◆ RWLockMap() [2/2]

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

Copy constructor.

Parameters
lmRWLockMap to copy

Definition at line 81 of file rwlock_map.h.

◆ ~RWLockMap()

template<typename KeyType , typename ValueType , typename LessKey >
fawkes::RWLockMap< KeyType, ValueType, LessKey >::~RWLockMap ( )
virtual

Destructor.

Definition at line 88 of file rwlock_map.h.

Member Function Documentation

◆ erase_locked()

template<typename KeyType , typename ValueType , typename LessKey >
void fawkes::RWLockMap< 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 147 of file rwlock_map.h.

◆ lock_for_read()

template<typename KeyType , typename ValueType , typename LessKey >
void fawkes::RWLockMap< KeyType, ValueType, LessKey >::lock_for_read ( )

Lock list for reading.

Definition at line 95 of file rwlock_map.h.

◆ lock_for_write()

template<typename KeyType , typename ValueType , typename LessKey >
void fawkes::RWLockMap< KeyType, ValueType, LessKey >::lock_for_write ( )

Lock list for writing.

Definition at line 104 of file rwlock_map.h.

◆ rwlock()

template<typename KeyType , typename ValueType , typename LessKey >
RefPtr< ReadWriteLock > fawkes::RWLockMap< KeyType, ValueType, LessKey >::rwlock ( ) const

Get access to the internal rwlock.

Can be used with RwlockLocker.

Returns
internal rwlock

Definition at line 161 of file rwlock_map.h.

◆ try_lock_for_read()

template<typename KeyType , typename ValueType , typename LessKey >
bool fawkes::RWLockMap< KeyType, ValueType, LessKey >::try_lock_for_read ( )

Try to lock list for reading.

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

Definition at line 115 of file rwlock_map.h.

◆ try_lock_for_write()

template<typename KeyType , typename ValueType , typename LessKey >
bool fawkes::RWLockMap< KeyType, ValueType, LessKey >::try_lock_for_write ( )

Try to lock list for writing.

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

Definition at line 126 of file rwlock_map.h.

◆ unlock()

template<typename KeyType , typename ValueType , typename LessKey >
void fawkes::RWLockMap< KeyType, ValueType, LessKey >::unlock ( )

Unlock list.

Definition at line 135 of file rwlock_map.h.


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