29 #ifndef PT_SYSTEM_QUEUE_H
30 #define PT_SYSTEM_QUEUE_H
32 #include <Pt/System/Api.h>
33 #include <Pt/System/Mutex.h>
34 #include <Pt/System/Condition.h>
54 typedef typename std::deque<T>::size_type size_type;
55 typedef typename std::deque<T>::const_reference const_reference;
61 std::deque<value_type> _queue;
63 size_type _numWaiting;
85 void put(const_reference element);
91 return _queue.empty();
124 template <
typename T>
130 while (_queue.empty())
131 _notEmpty.wait(lock);
134 value_type element = _queue.front();
145 template <
typename T>
150 while (_maxSize > 0 && _queue.size() >= _maxSize)
153 _queue.push_back(element);
156 if (_maxSize > 0 && _queue.size() < _maxSize)
160 template <
typename T>
165 if (_queue.size() < _maxSize)
173 #endif // PT_SYSTEM_QUEUE_H
size_type numWaiting() const
returns the number of threads blocked in the get method.
Definition: Queue.h:117
Signal and wait synchronisation promitive.
Definition: Condition.h:43
void put(const_reference element)
Adds a element to the queue.
Definition: Queue.h:146
value_type get()
Returns the next element.
Definition: Queue.h:125
bool empty() const
Returns true, if the queue is empty.
Definition: Queue.h:88
Mutual exclusion device.
Definition: Mutex.h:48
This class implements a thread safe queue.
Definition: Queue.h:50
size_type size() const
Returns the number of elements currently in queue.
Definition: Queue.h:95
Queue()
Default Constructor.
Definition: Queue.h:67
size_type maxSize() const
returns the maximum size of the queue.
Definition: Queue.h:110
MutexLock class for Mutex.
Definition: Mutex.h:126