Public Types | Public Member Functions

fawkes::LockSet< KeyType, LessKey > Class Template Reference
[Fawkes Core Library]

Set with a lock. More...

#include <>>

Inheritance diagram for fawkes::LockSet< KeyType, LessKey >:
Inheritance graph
[legend]

List of all members.

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< Mutexmutex () 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.

Detailed Description

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

Set with a lock.

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


Member Typedef Documentation

template<typename KeyType, typename LessKey = std::less<KeyType>>
typedef std::set<KeyType, LessKey>::iterator fawkes::LockSet< KeyType, LessKey >::iterator

Iterator.

Definition at line 49 of file lock_set.h.


Constructor & Destructor Documentation

template<typename KeyType , typename LessKey >
fawkes::LockSet< KeyType, LessKey >::LockSet (  ) 

Constructor.

Definition at line 76 of file lock_set.h.

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

Copy constructor.

Parameters:
lm LockSet to copy

Definition at line 85 of file lock_set.h.

template<typename KeyType , typename LessKey >
fawkes::LockSet< KeyType, LessKey >::~LockSet (  )  [virtual]

Destructor.

Definition at line 93 of file lock_set.h.


Member Function Documentation

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

Remove item with lock.

The set is automatically locked and unlocked during the removal.

Parameters:
key key of the value to erase

Definition at line 148 of file lock_set.h.

template<typename KeyType, typename LessKey >
std::pair< typename LockSet< KeyType, LessKey >::iterator, bool > fawkes::LockSet< KeyType, LessKey >::insert_locked ( const KeyType &  key  ) 

Insert item with lock.

The set is automatically locked and unlocked during the removal.

Parameters:
key key of the value to insert
Returns:
iterator to inserted item

Definition at line 133 of file lock_set.h.

template<typename KeyType , typename LessKey >
void fawkes::LockSet< KeyType, LessKey >::lock (  )  const
template<typename KeyType , typename LessKey >
RefPtr< Mutex > fawkes::LockSet< KeyType, LessKey >::mutex (  )  const

Get access to the internal mutex.

Can be used with MutexLocker.

Returns:
internal mutex

Definition at line 162 of file lock_set.h.

template<typename KeyType, typename LessKey>
LockSet< KeyType, LessKey > & fawkes::LockSet< KeyType, LessKey >::operator= ( const std::set< KeyType, LessKey > &  l  ) 

Copy values from a standard set.

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

Parameters:
l set to copy
Returns:
reference to this instance

Definition at line 200 of file lock_set.h.

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

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.

Parameters:
ll lock set to copy
Returns:
reference to this instance

Definition at line 176 of file lock_set.h.

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

template<typename KeyType , typename LessKey >
bool fawkes::LockSet< KeyType, LessKey >::try_lock (  )  const

Try to lock list.

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

Definition at line 111 of file lock_set.h.

template<typename KeyType , typename LessKey >
void fawkes::LockSet< KeyType, LessKey >::unlock (  )  const

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