Set with a lock. More...
#include <core/utils/lock_set.h>
Public Types | |
typedef std::set< KeyType, LessKey >::iterator | iterator |
Iterator. | |
Public Member Functions | |
LockSet () | |
Constructor. | |
LockSet (const LockSet< KeyType, LessKey > &lm) | |
Copy constructor. | |
virtual | ~LockSet () |
Destructor. | |
void | lock () const |
Lock list. | |
bool | try_lock () const |
Try to lock list. | |
void | unlock () const |
Unlock list. | |
RefPtr< Mutex > | mutex () const |
Get access to the internal mutex. | |
std::pair< iterator, bool > | insert_locked (const KeyType &key) |
Insert item with lock. | |
void | erase_locked (const KeyType &key) |
Remove item with lock. | |
LockSet< KeyType, LessKey > & | operator= (const LockSet< KeyType, LessKey > &ll) |
Copy values from another LockSet. | |
LockSet< KeyType, LessKey > & | operator= (const std::set< KeyType, LessKey > &l) |
Copy values from a standard set. |
Set with a lock.
This class provides a set that has an intrinsic lock. The lock can be applied with the regular locking methods.
Definition at line 36 of file lock_set.h.
typedef std::set<KeyType, LessKey>::iterator fawkes::LockSet< KeyType, LessKey >::iterator |
Iterator.
Definition at line 49 of file lock_set.h.
fawkes::LockSet< KeyType, LessKey >::LockSet | ( | ) | [inline] |
Constructor.
Definition at line 76 of file lock_set.h.
fawkes::LockSet< KeyType, LessKey >::LockSet | ( | const LockSet< KeyType, LessKey > & | lm | ) | [inline] |
fawkes::LockSet< KeyType, LessKey >::~LockSet | ( | ) | [inline, virtual] |
Destructor.
Definition at line 93 of file lock_set.h.
void fawkes::LockSet< KeyType, LessKey >::erase_locked | ( | const KeyType & | key | ) | [inline] |
Remove item with lock.
The set is automatically locked and unlocked during the removal.
key | key of the value to erase |
Definition at line 148 of file lock_set.h.
std::pair< typename LockSet< KeyType, LessKey >::iterator, bool > fawkes::LockSet< KeyType, LessKey >::insert_locked | ( | const KeyType & | key | ) | [inline] |
Insert item with lock.
The set is automatically locked and unlocked during the removal.
key | key of the value to insert |
Definition at line 133 of file lock_set.h.
void fawkes::LockSet< KeyType, LessKey >::lock | ( | ) | const [inline] |
Lock list.
Definition at line 100 of file lock_set.h.
Referenced by WorldModelObjPosMajorityFuser::fuse(), fawkes::LockSet< KeyType, LessKey >::operator=(), and WorldModelObjPosMajorityFuser::~WorldModelObjPosMajorityFuser().
RefPtr< Mutex > fawkes::LockSet< KeyType, LessKey >::mutex | ( | ) | const [inline] |
Get access to the internal mutex.
Can be used with MutexLocker.
Definition at line 162 of file lock_set.h.
LockSet< KeyType, LessKey > & fawkes::LockSet< KeyType, LessKey >::operator= | ( | const std::set< KeyType, LessKey > & | l | ) | [inline] |
Copy values from a standard set.
Copies the values one by one. This instance is locked during the copying and cleared.
l | set to copy |
Definition at line 200 of file lock_set.h.
LockSet< KeyType, LessKey > & fawkes::LockSet< KeyType, LessKey >::operator= | ( | const LockSet< KeyType, LessKey > & | ll | ) | [inline] |
Copy values from another LockSet.
Copies the values one by one. Both instances are locked during the copying and this instance is cleared before copying.
ll | lock set to copy |
Definition at line 176 of file lock_set.h.
References fawkes::LockSet< KeyType, LessKey >::lock(), and fawkes::LockSet< KeyType, LessKey >::unlock().
bool fawkes::LockSet< KeyType, LessKey >::try_lock | ( | ) | const [inline] |
Try to lock list.
Definition at line 111 of file lock_set.h.
void fawkes::LockSet< KeyType, LessKey >::unlock | ( | ) | const [inline] |
Unlock list.
Definition at line 120 of file lock_set.h.
Referenced by WorldModelObjPosMajorityFuser::fuse(), fawkes::LockSet< KeyType, LessKey >::operator=(), and WorldModelObjPosMajorityFuser::~WorldModelObjPosMajorityFuser().