24 #ifndef _CORE_UTILS_RWLOCK_QUEUE_H_
25 #define _CORE_UTILS_RWLOCK_QUEUE_H_
27 #include <core/threading/read_write_lock.h>
28 #include <core/utils/refptr.h>
34 template <
typename Type>
71 template <
typename Type>
80 template <
typename Type>
87 template <
typename Type>
94 template <
typename Type>
98 rwlock_->lock_for_read();
102 template <
typename Type>
106 rwlock_->lock_for_write();
112 template <
typename Type>
116 return rwlock_->try_lock_for_read();
122 template <
typename Type>
126 return rwlock_->try_lock_for_write();
130 template <
typename Type>
134 return rwlock_->unlock();
140 template <
typename Type>
144 rwlock_->lock_for_write();
145 std::queue<Type>::push(x);
151 template <
typename Type>
155 rwlock_->lock_for_write();
156 std::queue<Type>::pop();
161 template <
typename Type>
165 rwlock_->lock_for_write();
166 while (!std::queue<Type>::empty()) {
167 std::queue<Type>::pop();
176 template <
typename Type>
Queue with a read/write lock.
void pop_locked()
Pop element from queue with lock protection.
void push_locked(const Type &x)
Push element to queue with lock protection.
RefPtr< ReadWriteLock > rwlock() const
Get access to the internal rwlock.
void clear()
Clear the queue.
void lock_for_write()
Lock queue for writing.
void lock_for_read()
Lock queue for reading.
bool try_lock_for_write()
Try to lock queue for writing.
void unlock()
Unlock list.
virtual ~RWLockQueue()
Destructor.
RWLockQueue()
Constructor.
bool try_lock_for_read()
Try to lock queue for reading.
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.