12#include <boost/circular_buffer.hpp> 
   13#include <boost/thread/condition.hpp> 
   14#include <boost/utility.hpp> 
   20template <
typename elem_type>
 
   26        _not_full_fcn  = std::bind(&bounded_buffer_detail<elem_type>::not_full, 
this);
 
   27        _not_empty_fcn = std::bind(&bounded_buffer_detail<elem_type>::not_empty, 
this);
 
 
   32        std::unique_lock<std::mutex> lock(_mutex);
 
   36        _buffer.push_front(elem);
 
   37        _empty_cond.notify_one();
 
 
   43        std::lock_guard<std::mutex> lock(_mutex);
 
   46            _buffer.push_front(elem);
 
   47            _empty_cond.notify_one();
 
   50            _buffer.push_front(elem);
 
   51            _empty_cond.notify_one();
 
 
   58        std::unique_lock<std::mutex> lock(_mutex);
 
   60            _full_cond.wait(lock, _not_full_fcn);
 
   62        _buffer.push_front(elem);
 
   63        _empty_cond.notify_one();
 
 
   68        std::unique_lock<std::mutex> lock(_mutex);
 
   70            if (not _full_cond.timed_wait(lock, to_time_dur(timeout), _not_full_fcn)) {
 
   74        _buffer.push_front(elem);
 
   75        _empty_cond.notify_one();
 
 
   81        std::unique_lock<std::mutex> lock(_mutex);
 
   82        if (_buffer.empty()) {
 
   86        _full_cond.notify_one();
 
 
   92        std::unique_lock<std::mutex> lock(_mutex);
 
   93        if (_buffer.empty()) {
 
   94            _empty_cond.wait(lock, _not_empty_fcn);
 
   97        _full_cond.notify_one();
 
 
  102        std::unique_lock<std::mutex> lock(_mutex);
 
  103        if (_buffer.empty()) {
 
  104            if (not _empty_cond.timed_wait(lock, to_time_dur(timeout), _not_empty_fcn)) {
 
  108        this->pop_back(elem);
 
  109        _full_cond.notify_one();
 
 
  115    boost::condition _empty_cond, _full_cond;
 
  116    boost::circular_buffer<elem_type> _buffer;
 
  118    bool not_full(
void)
 const 
  120        return not _buffer.full();
 
  122    bool not_empty(
void)
 const 
  124        return not _buffer.empty();
 
  127    std::function<bool(
void)> _not_full_fcn, _not_empty_fcn;
 
  137        elem           = _buffer.back();
 
  138        _buffer.back() = elem_type();
 
  142    static UHD_INLINE boost::posix_time::time_duration to_time_dur(
double timeout)
 
  144        return boost::posix_time::microseconds(
long(timeout * 1e6));
 
 
UHD_INLINE bool pop_with_haste(elem_type &elem)
Definition bounded_buffer.ipp:79
UHD_INLINE bool pop_with_timed_wait(elem_type &elem, double timeout)
Definition bounded_buffer.ipp:100
UHD_INLINE void pop_with_wait(elem_type &elem)
Definition bounded_buffer.ipp:90
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:66
UHD_INLINE void push_with_wait(const elem_type &elem)
Definition bounded_buffer.ipp:56
UHD_INLINE bool push_with_haste(const elem_type &elem)
Definition bounded_buffer.ipp:30
UHD_INLINE bool push_with_pop_on_full(const elem_type &elem)
Definition bounded_buffer.ipp:41
#define UHD_INLINE
Definition config.h:65
Definition adapter_id.hpp:11
Definition build_info.hpp:12
boost::noncopyable noncopyable
Definition noncopyable.hpp:45