Restructured concurrent FIFO queue to use a circular buffer. Thx to the

guys from last week for asking about such a thing.
This commit is contained in:
DennisOSRM
2012-04-06 15:07:28 +02:00
parent 7983063d05
commit 03deda313a
2 changed files with 17 additions and 11 deletions
+4 -10
View File
@@ -21,13 +21,11 @@ or see http://www.gnu.org/licenses/agpl.txt.
#ifndef CONCURRENTQUEUE_H_INCLUDED
#define CONCURRENTQUEUE_H_INCLUDED
#include <boost/circular_buffer.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/condition.hpp>
#include <boost/thread/thread.hpp>
#include <boost/call_traits.hpp>
#include <boost/progress.hpp>
#include <boost/bind.hpp>
#include <boost/circular_buffer.hpp>
#include <boost/thread/condition.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/thread.hpp>
#include "../typedefs.h"
@@ -65,7 +63,6 @@ public:
if(internal_queue.empty()) {
return false;
}
popped_value=internal_queue.front();
internal_queue.pop_front();
lock.unlock();
@@ -73,8 +70,6 @@ public:
return true;
}
private:
boost::circular_buffer<Data> internal_queue;
boost::mutex m_mutex;
@@ -83,7 +78,6 @@ private:
inline bool is_not_empty() const { return internal_queue.size() > 0; }
inline bool is_not_full() const { return internal_queue.size() < internal_queue.capacity(); }
};
#endif //#ifndef CONCURRENTQUEUE_H_INCLUDED