Fawkes API  Fawkes Development Version
fawkes::RWLockVector< Type > Class Template Reference

Vector with a lock. More...

#include <>>

Inheritance diagram for fawkes::RWLockVector< Type >:

Public Member Functions

 RWLockVector ()
 Constructor. More...
 
 RWLockVector (const RWLockVector< Type > &lv)
 Copy constructor. More...
 
virtual ~RWLockVector ()
 Destructor. More...
 
virtual void lock_for_read () const
 Lock vector for reading. More...
 
virtual void lock_for_write () const
 Lock vector for writing. More...
 
virtual bool try_lock_for_read () const
 Try to lock vector for reading. More...
 
virtual bool try_lock_for_write () const
 Try to lock vector for writing. More...
 
virtual void unlock () const
 Unlock vector. More...
 
RefPtr< ReadWriteLockrwlock () const
 Get access to the internal read/write lock. More...
 
void push_back_locked (const Type &x)
 Push element to vector at back with lock protection. More...
 
void pop_back_locked ()
 Remove last element with lock protection. More...
 
void erase_locked (typename std::vector< Type >::iterator pos)
 Erase given element with lock protection. More...
 
void erase_locked (typename std::vector< Type >::iterator first, typename std::vector< Type >::iterator last)
 Erase given element range with lock protection. More...
 
RWLockVector< Type > & operator= (const RWLockVector< Type > &lv)
 Copy values from another RWLockVector. More...
 
RWLockVector< Type > & operator= (const std::vector< Type > &v)
 Copy values from a standard vector. More...
 

Detailed Description

template<typename Type>
class fawkes::RWLockVector< Type >

Vector with a lock.

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

See also
ReadWriteLock
Author
Tim Niemueller

Definition at line 37 of file rwlock_vector.h.

Constructor & Destructor Documentation

◆ RWLockVector() [1/2]

template<typename Type >
fawkes::RWLockVector< Type >::RWLockVector ( )

Constructor.

Definition at line 77 of file rwlock_vector.h.

◆ RWLockVector() [2/2]

template<typename Type>
fawkes::RWLockVector< Type >::RWLockVector ( const RWLockVector< Type > &  lv)

Copy constructor.

Parameters
lvRWLockVector to copy

Definition at line 86 of file rwlock_vector.h.

◆ ~RWLockVector()

template<typename Type >
fawkes::RWLockVector< Type >::~RWLockVector ( )
virtual

Destructor.

Definition at line 93 of file rwlock_vector.h.

Member Function Documentation

◆ erase_locked() [1/2]

template<typename Type>
void fawkes::RWLockVector< Type >::erase_locked ( typename std::vector< Type >::iterator  pos)

Erase given element with lock protection.

Parameters
positerator for the object position to remove

Definition at line 175 of file rwlock_vector.h.

◆ erase_locked() [2/2]

template<typename Type>
void fawkes::RWLockVector< Type >::erase_locked ( typename std::vector< Type >::iterator  first,
typename std::vector< Type >::iterator  last 
)

Erase given element range with lock protection.

Parameters
firstiterator to first element to erase
lastiterator to first element not to erase

Definition at line 188 of file rwlock_vector.h.

◆ lock_for_read()

template<typename Type >
void fawkes::RWLockVector< Type >::lock_for_read ( ) const
virtual

◆ lock_for_write()

◆ operator=() [1/2]

template<typename Type>
RWLockVector< Type > & fawkes::RWLockVector< Type >::operator= ( const RWLockVector< Type > &  lv)

Copy values from another RWLockVector.

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

Parameters
lvvector to copy
Returns
reference to this instance

Definition at line 216 of file rwlock_vector.h.

◆ operator=() [2/2]

template<typename Type>
RWLockVector< Type > & fawkes::RWLockVector< Type >::operator= ( const std::vector< Type > &  v)

Copy values from a standard vector.

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

Parameters
vvector to copy
Returns
reference to this instance

Definition at line 240 of file rwlock_vector.h.

◆ pop_back_locked()

template<typename Type >
void fawkes::RWLockVector< Type >::pop_back_locked ( )

Remove last element with lock protection.

Definition at line 162 of file rwlock_vector.h.

◆ push_back_locked()

template<typename Type>
void fawkes::RWLockVector< Type >::push_back_locked ( const Type &  x)

Push element to vector at back with lock protection.

Parameters
xelement to add

Definition at line 151 of file rwlock_vector.h.

◆ rwlock()

template<typename Type >
RefPtr< ReadWriteLock > fawkes::RWLockVector< Type >::rwlock ( ) const

Get access to the internal read/write lock.

Returns
internal read/write lock

Definition at line 202 of file rwlock_vector.h.

Referenced by RRDThread::add_data(), RRDThread::add_graph(), RRDThread::add_rrd(), RRDThread::generate_graphs(), and RRDThread::remove_rrd().

◆ try_lock_for_read()

template<typename Type >
bool fawkes::RWLockVector< Type >::try_lock_for_read ( ) const
virtual

Try to lock vector for reading.

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

Definition at line 120 of file rwlock_vector.h.

Referenced by fawkes::RWLockVector< fawkes::RRDDefinition *>::try_lock_for_read().

◆ try_lock_for_write()

template<typename Type >
bool fawkes::RWLockVector< Type >::try_lock_for_write ( ) const
virtual

Try to lock vector for writing.

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

Definition at line 131 of file rwlock_vector.h.

Referenced by fawkes::RWLockVector< fawkes::RRDDefinition *>::try_lock_for_write().

◆ unlock()

template<typename Type >
void fawkes::RWLockVector< Type >::unlock ( ) const
virtual

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