Quark  0.1
AsyncQueue.h++
Go to the documentation of this file.
1 
2 #ifndef __libquark_util_AsyncQueue_hxx
3 #define __libquark_util_AsyncQueue_hxx
4 
5 #include <QQueue>
6 #include <QWaitCondition>
7 
8 namespace quark {
9 namespace util {
10 
17 template<typename T> class AsyncQueue : private QQueue<T*>
18 {
19  public:
20 
22  AsyncQueue(uint capacity);
23 
25  ~AsyncQueue();
26 
34  void offer(T* item);
35 
45  T* take(int timeout = -1);
46 
50  void clear();
51 
52  private:
53 
54  uint _capacity;
55  QMutex _mutex;
56  QWaitCondition _condP;
57  QWaitCondition _condC;
58 };
59 
60 #include <quark/AsyncQueueImpl.h++>
61 
62 } // namespace util
63 } // namespace quark
64 
65 #endif // __libquark_util_AsyncQueue_hxx
An asynchronous queue which can be accessed from multiple threads in a threadsafe way...
Definition: AsyncQueue.h++:17
void clear()
Clears the queue.
Definition: BarChartView.h++:6
AsyncQueue(uint capacity)
Constructs a new AsyncQueue with the given maximum capacity.
~AsyncQueue()
Destructor.
T * take(int timeout=-1)
Removes an item from the head of the queue.
void offer(T *item)
Offers an item to the queue.