12#include <boost/circular_buffer.hpp>
13#include <boost/thread/condition.hpp>
14#include <boost/thread/locks.hpp>
15#include <boost/utility.hpp>
18namespace uhd{
namespace transport{
33 boost::mutex::scoped_lock lock(_mutex);
38 _buffer.push_front(elem);
39 _empty_cond.notify_one();
45 boost::mutex::scoped_lock lock(_mutex);
49 _buffer.push_front(elem);
50 _empty_cond.notify_one();
54 _buffer.push_front(elem);
55 _empty_cond.notify_one();
62 boost::mutex::scoped_lock lock(_mutex);
65 _full_cond.wait(lock, _not_full_fcn);
67 _buffer.push_front(elem);
68 _empty_cond.notify_one();
73 boost::mutex::scoped_lock lock(_mutex);
76 if (not _full_cond.timed_wait(lock,
77 to_time_dur(timeout), _not_full_fcn))
82 _buffer.push_front(elem);
83 _empty_cond.notify_one();
89 boost::mutex::scoped_lock lock(_mutex);
95 _full_cond.notify_one();
101 boost::mutex::scoped_lock lock(_mutex);
104 _empty_cond.wait(lock, _not_empty_fcn);
106 this->pop_back(elem);
107 _full_cond.notify_one();
112 boost::mutex::scoped_lock lock(_mutex);
115 if (not _empty_cond.timed_wait(lock, to_time_dur(timeout),
121 this->pop_back(elem);
122 _full_cond.notify_one();
128 boost::condition _empty_cond, _full_cond;
129 boost::circular_buffer<elem_type> _buffer;
131 bool not_full(
void)
const{
return not _buffer.full();}
132 bool not_empty(
void)
const{
return not _buffer.empty();}
134 std::function<bool(
void)> _not_full_fcn, _not_empty_fcn;
144 elem = _buffer.back();
145 _buffer.back() = elem_type();
149 static UHD_INLINE boost::posix_time::time_duration to_time_dur(
double timeout)
151 return boost::posix_time::microseconds(
long(timeout*1e6));
Definition bounded_buffer.ipp:21
UHD_INLINE bool pop_with_haste(elem_type &elem)
Definition bounded_buffer.ipp:87
UHD_INLINE bool pop_with_timed_wait(elem_type &elem, double timeout)
Definition bounded_buffer.ipp:110
UHD_INLINE void pop_with_wait(elem_type &elem)
Definition bounded_buffer.ipp:99
bounded_buffer_detail(size_t capacity)
Definition bounded_buffer.ipp:24
UHD_INLINE bool push_with_timed_wait(const elem_type &elem, double timeout)
Definition bounded_buffer.ipp:71
UHD_INLINE void push_with_wait(const elem_type &elem)
Definition bounded_buffer.ipp:60
UHD_INLINE bool push_with_haste(const elem_type &elem)
Definition bounded_buffer.ipp:31
UHD_INLINE bool push_with_pop_on_full(const elem_type &elem)
Definition bounded_buffer.ipp:43
#define UHD_INLINE
Definition config.h:52
Definition build_info.hpp:12
boost::noncopyable noncopyable
Definition noncopyable.hpp:45