summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--host/include/uhd/transport/bounded_buffer.hpp43
-rw-r--r--host/include/uhd/transport/bounded_buffer.ipp30
-rw-r--r--[-rwxr-xr-x]host/lib/transport/gen_vrt_if_packet.py2
-rw-r--r--host/lib/transport/libusb1_zero_copy.cpp15
-rw-r--r--host/lib/transport/udp_zero_copy_asio.cpp32
-rw-r--r--host/lib/usrp/usrp1/soft_time_ctrl.cpp8
-rw-r--r--host/lib/usrp/usrp2/io_impl.cpp8
-rw-r--r--host/lib/usrp/usrp_e100/io_impl.cpp19
-rw-r--r--host/tests/buffer_test.cpp36
9 files changed, 92 insertions, 101 deletions
diff --git a/host/include/uhd/transport/bounded_buffer.hpp b/host/include/uhd/transport/bounded_buffer.hpp
index 33ded8cfd..412d73f17 100644
--- a/host/include/uhd/transport/bounded_buffer.hpp
+++ b/host/include/uhd/transport/bounded_buffer.hpp
@@ -18,8 +18,7 @@
#ifndef INCLUDED_UHD_TRANSPORT_BOUNDED_BUFFER_HPP
#define INCLUDED_UHD_TRANSPORT_BOUNDED_BUFFER_HPP
-#include <uhd/config.hpp>
-#include <boost/shared_ptr.hpp>
+#include <uhd/transport/bounded_buffer.ipp> //detail
namespace uhd{ namespace transport{
@@ -32,13 +31,16 @@ namespace uhd{ namespace transport{
*/
template <typename elem_type> class bounded_buffer{
public:
- typedef boost::shared_ptr<bounded_buffer<elem_type> > sptr;
/*!
- * Make a new bounded buffer object.
+ * Create a new bounded buffer object.
* \param capacity the bounded_buffer capacity
*/
- static sptr make(size_t capacity);
+ bounded_buffer(size_t capacity):
+ _detail(capacity)
+ {
+ /* NOP */
+ }
/*!
* Push a new element into the bounded buffer.
@@ -47,14 +49,18 @@ namespace uhd{ namespace transport{
* \param elem the new element to push
* \return true if the element fit without popping for space
*/
- virtual bool push_with_pop_on_full(const elem_type &elem) = 0;
+ bool push_with_pop_on_full(const elem_type &elem){
+ return _detail.push_with_pop_on_full(elem);
+ }
/*!
* Push a new element into the bounded_buffer.
* Wait until the bounded_buffer becomes non-full.
* \param elem the new element to push
*/
- virtual void push_with_wait(const elem_type &elem) = 0;
+ void push_with_wait(const elem_type &elem){
+ return _detail.push_with_wait(elem);
+ }
/*!
* Push a new element into the bounded_buffer.
@@ -63,21 +69,27 @@ namespace uhd{ namespace transport{
* \param timeout the timeout in seconds
* \return false when the operation times out
*/
- virtual bool push_with_timed_wait(const elem_type &elem, double timeout) = 0;
+ bool push_with_timed_wait(const elem_type &elem, double timeout){
+ return _detail.push_with_timed_wait(elem, timeout);
+ }
/*!
* Pop an element from the bounded_buffer immediately.
* \param elem the element reference pop to
* \return false when the bounded_buffer is empty
*/
- virtual bool pop_with_haste(elem_type &elem) = 0;
+ bool pop_with_haste(elem_type &elem){
+ return _detail.pop_with_haste(elem);
+ }
/*!
* Pop an element from the bounded_buffer.
* Wait until the bounded_buffer becomes non-empty.
* \param elem the element reference pop to
*/
- virtual void pop_with_wait(elem_type &elem) = 0;
+ void pop_with_wait(elem_type &elem){
+ return _detail.pop_with_wait(elem);
+ }
/*!
* Pop an element from the bounded_buffer.
@@ -86,16 +98,13 @@ namespace uhd{ namespace transport{
* \param timeout the timeout in seconds
* \return false when the operation times out
*/
- virtual bool pop_with_timed_wait(elem_type &elem, double timeout) = 0;
+ bool pop_with_timed_wait(elem_type &elem, double timeout){
+ return _detail.pop_with_timed_wait(elem, timeout);
+ }
- /*!
- * Clear all elements from the bounded_buffer.
- */
- virtual void clear(void) = 0;
+ private: bounded_buffer_detail<elem_type> _detail;
};
}} //namespace
-#include <uhd/transport/bounded_buffer.ipp>
-
#endif /* INCLUDED_UHD_TRANSPORT_BOUNDED_BUFFER_HPP */
diff --git a/host/include/uhd/transport/bounded_buffer.ipp b/host/include/uhd/transport/bounded_buffer.ipp
index 7bf182ee3..466c7a306 100644
--- a/host/include/uhd/transport/bounded_buffer.ipp
+++ b/host/include/uhd/transport/bounded_buffer.ipp
@@ -18,22 +18,24 @@
#ifndef INCLUDED_UHD_TRANSPORT_BOUNDED_BUFFER_IPP
#define INCLUDED_UHD_TRANSPORT_BOUNDED_BUFFER_IPP
+#include <uhd/config.hpp>
#include <boost/bind.hpp>
#include <boost/function.hpp>
#include <boost/circular_buffer.hpp>
#include <boost/thread/condition.hpp>
#include <boost/thread/locks.hpp>
-#include <boost/date_time/posix_time/posix_time_types.hpp>
namespace uhd{ namespace transport{ namespace{ /*anon*/
- template <typename elem_type>
- class bounded_buffer_impl : public bounded_buffer<elem_type>{
+ template <typename elem_type> class bounded_buffer_detail{
public:
- bounded_buffer_impl(size_t capacity) : _buffer(capacity){
- _not_full_fcn = boost::bind(&bounded_buffer_impl<elem_type>::not_full, this);
- _not_empty_fcn = boost::bind(&bounded_buffer_impl<elem_type>::not_empty, this);
+ bounded_buffer_detail(size_t capacity):
+ _buffer(capacity),
+ _not_full_fcn(boost::bind(&bounded_buffer_detail<elem_type>::not_full, this)),
+ _not_empty_fcn(boost::bind(&bounded_buffer_detail<elem_type>::not_empty, this))
+ {
+ /* NOP */
}
UHD_INLINE bool push_with_pop_on_full(const elem_type &elem){
@@ -100,13 +102,6 @@ namespace uhd{ namespace transport{ namespace{ /*anon*/
return true;
}
- UHD_INLINE void clear(void){
- boost::mutex::scoped_lock lock(_mutex);
- while (not_empty()) this->pop_back();
- lock.unlock();
- _full_cond.notify_one();
- }
-
private:
boost::mutex _mutex;
boost::condition _empty_cond, _full_cond;
@@ -137,13 +132,4 @@ namespace uhd{ namespace transport{ namespace{ /*anon*/
};
}}} //namespace
-namespace uhd{ namespace transport{
-
- template <typename elem_type> typename bounded_buffer<elem_type>::sptr
- bounded_buffer<elem_type>::make(size_t capacity){
- return typename bounded_buffer<elem_type>::sptr(new bounded_buffer_impl<elem_type>(capacity));
- }
-
-}} //namespace
-
#endif /* INCLUDED_UHD_TRANSPORT_BOUNDED_BUFFER_IPP */
diff --git a/host/lib/transport/gen_vrt_if_packet.py b/host/lib/transport/gen_vrt_if_packet.py
index bf740ffa9..3ba562d68 100755..100644
--- a/host/lib/transport/gen_vrt_if_packet.py
+++ b/host/lib/transport/gen_vrt_if_packet.py
@@ -205,7 +205,7 @@ void vrt::if_hdr_unpack_$(suffix)(
if_packet_info.has_tsf = true;
if_packet_info.tsf = boost::uint64_t($(XE_MACRO)(packet_buff[$num_header_words])) << 32;
#set $num_header_words += 1
- if_packet_info.tsf |= boost::uint64_t($(XE_MACRO)(packet_buff[$num_header_words])) << 0;
+ if_packet_info.tsf |= $(XE_MACRO)(packet_buff[$num_header_words]);
#set $num_header_words += 1
#else
if_packet_info.has_tsf = false;
diff --git a/host/lib/transport/libusb1_zero_copy.cpp b/host/lib/transport/libusb1_zero_copy.cpp
index 311a8953b..d4c82617c 100644
--- a/host/lib/transport/libusb1_zero_copy.cpp
+++ b/host/lib/transport/libusb1_zero_copy.cpp
@@ -99,8 +99,7 @@ private:
bool _input;
//! hold a bounded buffer of completed transfers
- typedef bounded_buffer<libusb_transfer *> lut_buff_type;
- lut_buff_type::sptr _completed_list;
+ bounded_buffer<libusb_transfer *> _completed_list;
//! a list of all transfer structs we allocated
std::vector<libusb_transfer *> _all_luts;
@@ -134,7 +133,7 @@ static void callback(libusb_transfer *lut){
* \param pointer to libusb_transfer
*/
void usb_endpoint::callback_handle_transfer(libusb_transfer *lut){
- _completed_list->push_with_wait(lut);
+ _completed_list.push_with_wait(lut);
}
@@ -153,9 +152,9 @@ usb_endpoint::usb_endpoint(
):
_handle(handle),
_endpoint(endpoint),
- _input(input)
+ _input(input),
+ _completed_list(num_transfers)
{
- _completed_list = lut_buff_type::make(num_transfers);
_buffer_pool = buffer_pool::make(num_transfers, transfer_size);
for (size_t i = 0; i < num_transfers; i++){
_all_luts.push_back(allocate_transfer(_buffer_pool->at(i), transfer_size));
@@ -163,7 +162,7 @@ usb_endpoint::usb_endpoint(
//input luts are immediately submitted to be filled
//output luts go into the completed list as free buffers
if (_input) this->submit(_all_luts.back());
- else _completed_list->push_with_wait(_all_luts.back());
+ else _completed_list.push_with_wait(_all_luts.back());
}
}
@@ -272,8 +271,8 @@ void usb_endpoint::print_transfer_status(libusb_transfer *lut){
libusb_transfer *usb_endpoint::get_lut_with_wait(double timeout){
boost::this_thread::disable_interruption di; //disable because the wait can throw
- libusb_transfer *lut;
- if (_completed_list->pop_with_timed_wait(lut, timeout)) return lut;
+ libusb_transfer *lut = NULL;
+ if (_completed_list.pop_with_timed_wait(lut, timeout)) return lut;
return NULL;
}
diff --git a/host/lib/transport/udp_zero_copy_asio.cpp b/host/lib/transport/udp_zero_copy_asio.cpp
index f083b97d8..0f16e7d14 100644
--- a/host/lib/transport/udp_zero_copy_asio.cpp
+++ b/host/lib/transport/udp_zero_copy_asio.cpp
@@ -72,6 +72,9 @@ public:
_num_recv_frames(size_t(hints.cast<double>("num_recv_frames", DEFAULT_NUM_FRAMES))),
_send_frame_size(size_t(hints.cast<double>("send_frame_size", udp_simple::mtu))),
_num_send_frames(size_t(hints.cast<double>("num_send_frames", DEFAULT_NUM_FRAMES))),
+ _recv_buffer_pool(buffer_pool::make(_num_recv_frames, _recv_frame_size)),
+ _send_buffer_pool(buffer_pool::make(_num_send_frames, _send_frame_size)),
+ _pending_recv_buffs(_num_recv_frames), _pending_send_buffs(_num_send_frames),
_concurrency_hint(hints.cast<size_t>("concurrency_hint", CONCURRENCY_HINT)),
_io_service(_concurrency_hint)
{
@@ -96,17 +99,13 @@ public:
}
void init(void){
- //allocate all recv frames and release them to begin xfers
- _pending_recv_buffs = pending_buffs_type::make(_num_recv_frames);
- _recv_buffer_pool = buffer_pool::make(_num_recv_frames, _recv_frame_size);
- for (size_t i = 0; i < _num_recv_frames; i++){
+ //release recv frames for use
+ for (size_t i = 0; i < get_num_recv_frames(); i++){
release(_recv_buffer_pool->at(i));
}
- //allocate all send frames and push them into the fifo
- _pending_send_buffs = pending_buffs_type::make(_num_send_frames);
- _send_buffer_pool = buffer_pool::make(_num_send_frames, _send_frame_size);
- for (size_t i = 0; i < _num_send_frames; i++){
+ //push send frames into the fifo
+ for (size_t i = 0; i < get_num_send_frames(); i++){
handle_send(_send_buffer_pool->at(i));
}
@@ -138,7 +137,7 @@ public:
//! handle a recv callback -> push the filled memory into the fifo
UHD_INLINE void handle_recv(void *mem, size_t len){
- _pending_recv_buffs->push_with_pop_on_full(boost::asio::buffer(mem, len));
+ _pending_recv_buffs.push_with_pop_on_full(boost::asio::buffer(mem, len));
}
////////////////////////////////////////////////////////////////////
@@ -148,7 +147,7 @@ public:
managed_recv_buffer::sptr get_recv_buff(double timeout){
boost::this_thread::disable_interruption di; //disable because the wait can throw
asio::mutable_buffer buff;
- if (_pending_recv_buffs->pop_with_timed_wait(buff, timeout)){
+ if (_pending_recv_buffs.pop_with_timed_wait(buff, timeout)){
return managed_recv_buffer::make_safe(
buff, boost::bind(
&udp_zero_copy_asio_impl::release, this,
@@ -191,7 +190,7 @@ public:
//if the condition is true, call receive and return the managed buffer
if (
::select(_sock_fd+1, &rset, NULL, NULL, &tv) > 0
- and _pending_recv_buffs->pop_with_haste(buff)
+ and _pending_recv_buffs.pop_with_haste(buff)
){
return managed_recv_buffer::make_safe(
asio::buffer(
@@ -220,7 +219,7 @@ public:
//! handle a send callback -> push the emptied memory into the fifo
UHD_INLINE void handle_send(void *mem){
- _pending_send_buffs->push_with_pop_on_full(boost::asio::buffer(mem, this->get_send_frame_size()));
+ _pending_send_buffs.push_with_pop_on_full(boost::asio::buffer(mem, this->get_send_frame_size()));
}
////////////////////////////////////////////////////////////////////
@@ -230,7 +229,7 @@ public:
managed_send_buffer::sptr get_send_buff(double timeout){
boost::this_thread::disable_interruption di; //disable because the wait can throw
asio::mutable_buffer buff;
- if (_pending_send_buffs->pop_with_timed_wait(buff, timeout)){
+ if (_pending_send_buffs.pop_with_timed_wait(buff, timeout)){
return managed_send_buffer::make_safe(
buff, boost::bind(
&udp_zero_copy_asio_impl::commit, this,
@@ -257,7 +256,7 @@ public:
////////////////////////////////////////////////////////////////////
managed_send_buffer::sptr get_send_buff(double){
asio::mutable_buffer buff;
- if (_pending_send_buffs->pop_with_haste(buff)){
+ if (_pending_send_buffs.pop_with_haste(buff)){
return managed_send_buffer::make_safe(
buff, boost::bind(
&udp_zero_copy_asio_impl::commit, this,
@@ -283,11 +282,10 @@ public:
private:
//memory management -> buffers and fifos
boost::thread_group _thread_group;
- buffer_pool::sptr _send_buffer_pool, _recv_buffer_pool;
- typedef bounded_buffer<asio::mutable_buffer> pending_buffs_type;
- pending_buffs_type::sptr _pending_recv_buffs, _pending_send_buffs;
const size_t _recv_frame_size, _num_recv_frames;
const size_t _send_frame_size, _num_send_frames;
+ buffer_pool::sptr _recv_buffer_pool, _send_buffer_pool;
+ bounded_buffer<asio::mutable_buffer> _pending_recv_buffs, _pending_send_buffs;
//asio guts -> socket and service
size_t _concurrency_hint;
diff --git a/host/lib/usrp/usrp1/soft_time_ctrl.cpp b/host/lib/usrp/usrp1/soft_time_ctrl.cpp
index 246df93eb..e1b671811 100644
--- a/host/lib/usrp/usrp1/soft_time_ctrl.cpp
+++ b/host/lib/usrp/usrp1/soft_time_ctrl.cpp
@@ -39,7 +39,7 @@ public:
soft_time_ctrl_impl(const cb_fcn_type &stream_on_off):
_nsamps_remaining(0),
_stream_mode(stream_cmd_t::STREAM_MODE_STOP_CONTINUOUS),
- _cmd_queue(bounded_buffer<boost::any>::make(2)),
+ _cmd_queue(2),
_stream_on_off(stream_on_off)
{
//synchronously spawn a new thread
@@ -112,7 +112,7 @@ public:
}
void issue_stream_cmd(const stream_cmd_t &cmd){
- _cmd_queue->push_with_wait(cmd);
+ _cmd_queue.push_with_wait(cmd);
}
void stream_on_off(bool enb){
@@ -180,7 +180,7 @@ public:
try{
boost::any cmd;
while (true){
- _cmd_queue->pop_with_wait(cmd);
+ _cmd_queue.pop_with_wait(cmd);
recv_cmd_handle_cmd(boost::any_cast<stream_cmd_t>(cmd));
}
} catch(const boost::thread_interrupted &){}
@@ -191,7 +191,7 @@ private:
size_t _nsamps_remaining;
stream_cmd_t::stream_mode_t _stream_mode;
time_spec_t _time_offset;
- bounded_buffer<boost::any>::sptr _cmd_queue;
+ bounded_buffer<boost::any> _cmd_queue;
const cb_fcn_type _stream_on_off;
boost::thread_group _thread_group;
};
diff --git a/host/lib/usrp/usrp2/io_impl.cpp b/host/lib/usrp/usrp2/io_impl.cpp
index 4d8074e70..36012bcfb 100644
--- a/host/lib/usrp/usrp2/io_impl.cpp
+++ b/host/lib/usrp/usrp2/io_impl.cpp
@@ -114,7 +114,7 @@ struct usrp2_impl::io_impl{
xports(xports),
packet_handler_recv_state(xports.size()),
packet_handler_send_state(xports.size()),
- async_msg_fifo(bounded_buffer<async_metadata_t>::make(100/*messages deep*/))
+ async_msg_fifo(100/*messages deep*/)
{
for (size_t i = 0; i < xports.size(); i++){
fc_mons.push_back(flow_control_monitor::sptr(
@@ -177,7 +177,7 @@ struct usrp2_impl::io_impl{
void recv_pirate_loop(zero_copy_if::sptr, usrp2_mboard_impl::sptr, size_t);
boost::thread_group recv_pirate_crew;
bool recv_pirate_crew_raiding;
- bounded_buffer<async_metadata_t>::sptr async_msg_fifo;
+ bounded_buffer<async_metadata_t> async_msg_fifo;
boost::mutex spawn_mutex;
};
@@ -230,7 +230,7 @@ void usrp2_impl::io_impl::recv_pirate_loop(
//print the famous U, and push the metadata into the message queue
if (metadata.event_code & underflow_flags) std::cerr << "U" << std::flush;
//else std::cout << "metadata.event_code " << metadata.event_code << std::endl;
- async_msg_fifo->push_with_pop_on_full(metadata);
+ async_msg_fifo.push_with_pop_on_full(metadata);
}
else{
//TODO unknown received packet, may want to print error...
@@ -276,7 +276,7 @@ bool usrp2_impl::recv_async_msg(
async_metadata_t &async_metadata, double timeout
){
boost::this_thread::disable_interruption di; //disable because the wait can throw
- return _io_impl->async_msg_fifo->pop_with_timed_wait(async_metadata, timeout);
+ return _io_impl->async_msg_fifo.pop_with_timed_wait(async_metadata, timeout);
}
/***********************************************************************
diff --git a/host/lib/usrp/usrp_e100/io_impl.cpp b/host/lib/usrp/usrp_e100/io_impl.cpp
index 2388482c7..c8b9e03d9 100644
--- a/host/lib/usrp/usrp_e100/io_impl.cpp
+++ b/host/lib/usrp/usrp_e100/io_impl.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -54,8 +54,8 @@ struct usrp_e100_impl::io_impl{
bool continuous_streaming;
io_impl(usrp_e100_iface::sptr iface):
data_xport(usrp_e100_make_mmap_zero_copy(iface)),
- recv_pirate_booty(recv_booty_type::make(data_xport->get_num_recv_frames())),
- async_msg_fifo(bounded_buffer<async_metadata_t>::make(100/*messages deep*/))
+ recv_pirate_booty(data_xport->get_num_recv_frames()),
+ async_msg_fifo(100/*messages deep*/)
{
/* NOP */
}
@@ -69,14 +69,13 @@ struct usrp_e100_impl::io_impl{
bool get_recv_buffs(vrt_packet_handler::managed_recv_buffs_t &buffs, double timeout){
UHD_ASSERT_THROW(buffs.size() == 1);
boost::this_thread::disable_interruption di; //disable because the wait can throw
- return recv_pirate_booty->pop_with_timed_wait(buffs.front(), timeout);
+ return recv_pirate_booty.pop_with_timed_wait(buffs.front(), timeout);
}
//a pirate's life is the life for me!
void recv_pirate_loop(usrp_e100_clock_ctrl::sptr);
- typedef bounded_buffer<managed_recv_buffer::sptr> recv_booty_type;
- recv_booty_type::sptr recv_pirate_booty;
- bounded_buffer<async_metadata_t>::sptr async_msg_fifo;
+ bounded_buffer<managed_recv_buffer::sptr> recv_pirate_booty;
+ bounded_buffer<async_metadata_t> async_msg_fifo;
boost::thread_group recv_pirate_crew;
bool recv_pirate_crew_raiding;
};
@@ -124,12 +123,12 @@ void usrp_e100_impl::io_impl::recv_pirate_loop(usrp_e100_clock_ctrl::sptr clock_
//print the famous U, and push the metadata into the message queue
if (metadata.event_code & underflow_flags) std::cerr << "U" << std::flush;
- async_msg_fifo->push_with_pop_on_full(metadata);
+ async_msg_fifo.push_with_pop_on_full(metadata);
continue;
}
//same number of frames as the data transport -> always immediate
- recv_pirate_booty->push_with_wait(buff);
+ recv_pirate_booty.push_with_wait(buff);
}catch(const std::exception &e){
std::cerr << "Error (usrp-e recv pirate loop): " << e.what() << std::endl;
@@ -266,5 +265,5 @@ bool usrp_e100_impl::recv_async_msg(
async_metadata_t &async_metadata, double timeout
){
boost::this_thread::disable_interruption di; //disable because the wait can throw
- return _io_impl->async_msg_fifo->pop_with_timed_wait(async_metadata, timeout);
+ return _io_impl->async_msg_fifo.pop_with_timed_wait(async_metadata, timeout);
}
diff --git a/host/tests/buffer_test.cpp b/host/tests/buffer_test.cpp
index e7bc88699..23b52a9bf 100644
--- a/host/tests/buffer_test.cpp
+++ b/host/tests/buffer_test.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -25,40 +25,40 @@ using namespace uhd::transport;
static const double timeout = 0.01/*secs*/;
BOOST_AUTO_TEST_CASE(test_bounded_buffer_with_timed_wait){
- bounded_buffer<int>::sptr bb(bounded_buffer<int>::make(3));
+ bounded_buffer<int> bb(3);
//push elements, check for timeout
- BOOST_CHECK(bb->push_with_timed_wait(0, timeout));
- BOOST_CHECK(bb->push_with_timed_wait(1, timeout));
- BOOST_CHECK(bb->push_with_timed_wait(2, timeout));
- BOOST_CHECK(not bb->push_with_timed_wait(3, timeout));
+ BOOST_CHECK(bb.push_with_timed_wait(0, timeout));
+ BOOST_CHECK(bb.push_with_timed_wait(1, timeout));
+ BOOST_CHECK(bb.push_with_timed_wait(2, timeout));
+ BOOST_CHECK(not bb.push_with_timed_wait(3, timeout));
int val;
//pop elements, check for timeout and check values
- BOOST_CHECK(bb->pop_with_timed_wait(val, timeout));
+ BOOST_CHECK(bb.pop_with_timed_wait(val, timeout));
BOOST_CHECK_EQUAL(val, 0);
- BOOST_CHECK(bb->pop_with_timed_wait(val, timeout));
+ BOOST_CHECK(bb.pop_with_timed_wait(val, timeout));
BOOST_CHECK_EQUAL(val, 1);
- BOOST_CHECK(bb->pop_with_timed_wait(val, timeout));
+ BOOST_CHECK(bb.pop_with_timed_wait(val, timeout));
BOOST_CHECK_EQUAL(val, 2);
- BOOST_CHECK(not bb->pop_with_timed_wait(val, timeout));
+ BOOST_CHECK(not bb.pop_with_timed_wait(val, timeout));
}
BOOST_AUTO_TEST_CASE(test_bounded_buffer_with_pop_on_full){
- bounded_buffer<int>::sptr bb(bounded_buffer<int>::make(3));
+ bounded_buffer<int> bb(3);
//push elements, check for timeout
- BOOST_CHECK(bb->push_with_pop_on_full(0));
- BOOST_CHECK(bb->push_with_pop_on_full(1));
- BOOST_CHECK(bb->push_with_pop_on_full(2));
- BOOST_CHECK(not bb->push_with_pop_on_full(3));
+ BOOST_CHECK(bb.push_with_pop_on_full(0));
+ BOOST_CHECK(bb.push_with_pop_on_full(1));
+ BOOST_CHECK(bb.push_with_pop_on_full(2));
+ BOOST_CHECK(not bb.push_with_pop_on_full(3));
int val;
//pop elements, check for timeout and check values
- BOOST_CHECK(bb->pop_with_timed_wait(val, timeout));
+ BOOST_CHECK(bb.pop_with_timed_wait(val, timeout));
BOOST_CHECK_EQUAL(val, 1);
- BOOST_CHECK(bb->pop_with_timed_wait(val, timeout));
+ BOOST_CHECK(bb.pop_with_timed_wait(val, timeout));
BOOST_CHECK_EQUAL(val, 2);
- BOOST_CHECK(bb->pop_with_timed_wait(val, timeout));
+ BOOST_CHECK(bb.pop_with_timed_wait(val, timeout));
BOOST_CHECK_EQUAL(val, 3);
}