1 #ifndef BITES_CONCURRENTQUEUE_HPP_INCLUDED
2 #define BITES_CONCURRENTQUEUE_HPP_INCLUDED
5 #include <boost/thread/mutex.hpp>
6 #include <boost/thread/condition_variable.hpp>
15 template<
typename Data>
19 std::queue<Data> the_queue;
20 mutable boost::mutex the_mutex;
21 boost::condition_variable the_condition_variable;
25 void push(Data
const& data)
27 boost::mutex::scoped_lock lock(the_mutex);
30 the_condition_variable.notify_one();
37 boost::mutex::scoped_lock lock(the_mutex);
38 return the_queue.empty();
45 boost::mutex::scoped_lock lock(the_mutex);
51 popped_value=the_queue.front();
60 boost::mutex::scoped_lock lock(the_mutex);
61 while(the_queue.empty())
63 the_condition_variable.wait(lock);
66 popped_value=the_queue.front();
72 typename std::queue<Data>::size_type
size()
74 boost::mutex::scoped_lock lock(the_mutex);
75 return the_queue.size();
82 #endif // BITES_CONCURRENTQUEUE_HPP_INCLUDED
std::queue< Data >::size_type size()
Definition: ConcurrentQueue.hpp:72
Definition: ConcurrentQueue.hpp:16
bool try_pop(Data &popped_value)
Definition: ConcurrentQueue.hpp:43
bool empty() const
Definition: ConcurrentQueue.hpp:35
void push(Data const &data)
Definition: ConcurrentQueue.hpp:25
void wait_and_pop(Data &popped_value)
Definition: ConcurrentQueue.hpp:58