From 65c4693c873533d1dc852dedcd4559920ff20da7 Mon Sep 17 00:00:00 2001 From: "Vicente J. Botet Escriba" Date: Sat, 28 Feb 2015 10:41:20 +0100 Subject: [PATCH] Add missing push(movable&&) and Run some failing tests that work when BOOST_NO_CXX11_RVALUE_REFERENCES is not defined. --- .../concurrent_queues/sync_timed_queue.hpp | 21 +++++++++ .../sync_pq/pq_single_thread_pass.cpp | 44 +++++++++---------- 2 files changed, 41 insertions(+), 24 deletions(-) diff --git a/include/boost/thread/concurrent_queues/sync_timed_queue.hpp b/include/boost/thread/concurrent_queues/sync_timed_queue.hpp index 78712e58..8f24f43e 100644 --- a/include/boost/thread/concurrent_queues/sync_timed_queue.hpp +++ b/include/boost/thread/concurrent_queues/sync_timed_queue.hpp @@ -106,6 +106,11 @@ namespace detail template void push(const T& elem, chrono::duration const& dura); + template + void push(BOOST_THREAD_RV_REF(T) elem, chrono::time_point const& tp); + template + void push(BOOST_THREAD_RV_REF(T) elem, chrono::duration const& dura); + template queue_op_status try_push(const T& elem, chrono::time_point const& tp); template @@ -158,6 +163,22 @@ namespace detail push(elem, clock::now() + dura); } + template + template + void sync_timed_queue::push(BOOST_THREAD_RV_REF(T) elem, chrono::time_point const& tp) + { + super::push(stype(boost::move(elem),tp)); + } + + template + template + void sync_timed_queue::push(BOOST_THREAD_RV_REF(T) elem, chrono::duration const& dura) + { + push(boost::move(elem), clock::now() + dura); + } + + + template template queue_op_status sync_timed_queue::try_push(const T& elem, chrono::time_point const& tp) diff --git a/test/sync/mutual_exclusion/sync_pq/pq_single_thread_pass.cpp b/test/sync/mutual_exclusion/sync_pq/pq_single_thread_pass.cpp index 7d6af4a1..70cb21bd 100644 --- a/test/sync/mutual_exclusion/sync_pq/pq_single_thread_pass.cpp +++ b/test/sync/mutual_exclusion/sync_pq/pq_single_thread_pass.cpp @@ -149,17 +149,15 @@ int main() //test_pull_until_when_not_empty(); #if ! defined BOOST_NO_CXX11_RVALUE_REFERENCES -#if 0 { // empty queue try_push rvalue/non-copyable succeeds boost::concurrent::sync_priority_queue q; - BOOST_TEST(boost::queue_op_status::success ==q.try_push(non_copyable())); + BOOST_TEST(boost::queue_op_status::success ==q.try_push(non_copyable(1))); BOOST_TEST(! q.empty()); BOOST_TEST(! q.full()); BOOST_TEST_EQ(q.size(), 1u); BOOST_TEST(! q.closed()); } -#endif { //fixme // empty queue try_push rvalue/non-copyable succeeds @@ -183,17 +181,16 @@ int main() BOOST_TEST_EQ(q.size(), 1u); BOOST_TEST(! q.closed()); } -// { -// // empty queue try_push rvalue succeeds -// boost::concurrent::sync_priority_queue q; -// BOOST_TEST(boost::queue_op_status::success == q.nonblocking_push(1)); -// BOOST_TEST(! q.empty()); -// BOOST_TEST(! q.full()); -// BOOST_TEST_EQ(q.size(), 1u); -// BOOST_TEST(! q.closed()); -// } -#if ! defined BOOST_NO_CXX11_RVALUE_REFERENCES #if 0 + { + // empty queue try_push rvalue succeeds + boost::concurrent::sync_priority_queue q; + BOOST_TEST(boost::queue_op_status::success == q.nonblocking_push(1)); + BOOST_TEST(! q.empty()); + BOOST_TEST(! q.full()); + BOOST_TEST_EQ(q.size(), 1u); + BOOST_TEST(! q.closed()); + } { // empty queue nonblocking_push rvalue/non-copyable succeeds boost::concurrent::sync_priority_queue q; @@ -203,17 +200,16 @@ int main() BOOST_TEST_EQ(q.size(), 1u); BOOST_TEST(! q.closed()); } -#endif -// { -// // empty queue nonblocking_push rvalue/non-copyable succeeds -// boost::concurrent::sync_priority_queue q; -// non_copyable nc(1); -// BOOST_TEST(boost::queue_op_status::success == q.nonblocking_push(boost::move(nc))); -// BOOST_TEST(! q.empty()); -// BOOST_TEST(! q.full()); -// BOOST_TEST_EQ(q.size(), 1u); -// BOOST_TEST(! q.closed()); -// } + { + // empty queue nonblocking_push rvalue/non-copyable succeeds + boost::concurrent::sync_priority_queue q; + non_copyable nc(1); + BOOST_TEST(boost::queue_op_status::success == q.nonblocking_push(boost::move(nc))); + BOOST_TEST(! q.empty()); + BOOST_TEST(! q.full()); + BOOST_TEST_EQ(q.size(), 1u); + BOOST_TEST(! q.closed()); + } #endif {