24#ifndef _CORE_UTILS_RWLOCK_VECTOR_H_
25#define _CORE_UTILS_RWLOCK_VECTOR_H_
27#include <core/threading/read_write_lock.h>
28#include <core/utils/refptr.h>
34template <
typename Type>
52 typename std::vector<Type>::iterator last);
72template <
typename Type>
80template <
typename Type>
87template <
typename Type>
93template <
typename Type>
97 rwlock_->lock_for_read();
101template <
typename Type>
105 rwlock_->lock_for_write();
111template <
typename Type>
115 return rwlock_->try_lock_for_read();
121template <
typename Type>
125 return rwlock_->try_lock_for_write();
129template <
typename Type>
133 return rwlock_->unlock();
139template <
typename Type>
143 rwlock_->lock_for_write();
144 std::vector<Type>::push_back(x);
149template <
typename Type>
153 rwlock_->lock_for_write();
154 std::vector<Type>::pop_back();
161template <
typename Type>
165 rwlock_->lock_for_write();
166 std::vector<Type>::erase(pos);
174template <
typename Type>
177 typename std::vector<Type>::iterator last)
179 rwlock_->lock_for_write();
180 std::vector<Type>::erase(first, last);
187template <
typename Type>
200template <
typename Type>
204 rwlock_->lock_for_write();
208 for (i = lv.begin(); i != lv.end(); ++i) {
223template <
typename Type>
227 rwlock_->lock_for_write();
229 typename std::vector<Type>::const_iterator i;
230 for (i = v.begin(); i != v.end(); ++i) {
RWLockVector()
Constructor.
RefPtr< ReadWriteLock > rwlock() const
Get access to the internal read/write lock.
RWLockVector< Type > & operator=(const RWLockVector< Type > &lv)
Copy values from another RWLockVector.
void erase_locked(typename std::vector< Type >::iterator pos)
Erase given element with lock protection.
void push_back_locked(const Type &x)
Push element to vector at back with lock protection.
virtual ~RWLockVector()
Destructor.
virtual void unlock() const
Unlock vector.
virtual void lock_for_read() const
Lock vector for reading.
virtual bool try_lock_for_write() const
Try to lock vector for writing.
RWLockVector< Type > & operator=(const std::vector< Type > &v)
Copy values from a standard vector.
void erase_locked(typename std::vector< Type >::iterator first, typename std::vector< Type >::iterator last)
Erase given element range with lock protection.
RWLockVector(const RWLockVector< Type > &lv)
Copy constructor.
void pop_back_locked()
Remove last element with lock protection.
virtual bool try_lock_for_read() const
Try to lock vector for reading.
virtual void lock_for_write() const
Lock vector for writing.
Read/write lock to allow multiple readers but only a single writer on the resource at a time.
RefPtr<> is a reference-counting shared smartpointer.
Fawkes library namespace.