comparison Core/MultiThreading/SharedMessageQueue.h @ 1227:7266c37d0354

lifo policy in SharedMessageQueue
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 20 Nov 2014 11:58:47 +0100
parents 8c67382f44a7
children 6e7e5ed91c2d
comparison
equal deleted inserted replaced
1226:3f62e1269cca 1227:7266c37d0354
43 class SharedMessageQueue : public boost::noncopyable 43 class SharedMessageQueue : public boost::noncopyable
44 { 44 {
45 private: 45 private:
46 typedef std::list<IDynamicObject*> Queue; 46 typedef std::list<IDynamicObject*> Queue;
47 47
48 bool isFifo_;
48 unsigned int maxSize_; 49 unsigned int maxSize_;
49 Queue queue_; 50 Queue queue_;
50 boost::mutex mutex_; 51 boost::mutex mutex_;
51 boost::condition_variable elementAvailable_; 52 boost::condition_variable elementAvailable_;
52 boost::condition_variable emptied_; 53 boost::condition_variable emptied_;
61 62
62 // The caller is responsible to delete the dequeud message! 63 // The caller is responsible to delete the dequeud message!
63 IDynamicObject* Dequeue(int32_t millisecondsTimeout); 64 IDynamicObject* Dequeue(int32_t millisecondsTimeout);
64 65
65 bool WaitEmpty(int32_t millisecondsTimeout); 66 bool WaitEmpty(int32_t millisecondsTimeout);
67
68 bool IsFifoPolicy() const
69 {
70 return isFifo_;
71 }
72
73 bool IsLifoPolicy() const
74 {
75 return !isFifo_;
76 }
77
78 void SetFifoPolicy();
79
80 void SetLifoPolicy();
66 }; 81 };
67 } 82 }