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:
parent
7983063d05
commit
03deda313a
@ -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
|
||||
|
14
SConstruct
14
SConstruct
@ -185,6 +185,9 @@ if not conf.CheckCXXHeader('boost/archive/iterators/transform_width.hpp'):
|
||||
if not conf.CheckCXXHeader('boost/bind.hpp'):
|
||||
print "boost/bind.hpp not found. Exiting"
|
||||
Exit(-1)
|
||||
if not conf.CheckCXXHeader('boost/circular_buffer.hpp'):
|
||||
print "boost/circular_buffer.hpp not found. Exiting"
|
||||
Exit(-1)
|
||||
if not conf.CheckCXXHeader('boost/enable_shared_from_this.hpp'):
|
||||
print "boost/bind.hpp not found. Exiting"
|
||||
Exit(-1)
|
||||
@ -212,9 +215,18 @@ if not conf.CheckCXXHeader('boost/property_tree/ini_parser.hpp'):
|
||||
if not conf.CheckCXXHeader('boost/shared_ptr.hpp'):
|
||||
print "boost/shared_ptr.hpp not found. Exiting"
|
||||
Exit(-1)
|
||||
if not conf.CheckCXXHeader('boost/signals2/mutex.hpp'):
|
||||
if not conf.CheckCXXHeader('boost/thread/mutex.hpp'):
|
||||
print "boost/shared_ptr.hpp not found. Exiting"
|
||||
Exit(-1)
|
||||
if not conf.CheckCXXHeader('boost/thread/thread.hpp'):
|
||||
print "boost/thread/thread.hpp not found. Exiting"
|
||||
Exit(-1)
|
||||
if not conf.CheckCXXHeader('boost/thread/condition.hpp'):
|
||||
print "boost/thread/condition.hpp not found. Exiting"
|
||||
Exit(-1)
|
||||
if not conf.CheckCXXHeader('boost/thread/thread.hpp'):
|
||||
print "boost/thread/thread.hpp not found. Exiting"
|
||||
Exit(-1)
|
||||
if not conf.CheckCXXHeader('boost/thread.hpp'):
|
||||
print "boost thread header not found. Exiting"
|
||||
Exit(-1)
|
||||
|
Loading…
Reference in New Issue
Block a user