summaryrefslogtreecommitdiff
path: root/libs/thread/test
diff options
context:
space:
mode:
Diffstat (limited to 'libs/thread/test')
-rw-r--r--libs/thread/test/Jamfile.v275
-rw-r--r--libs/thread/test/experimental/parallel/v1/exception_list_pass.cpp23
-rw-r--r--libs/thread/test/experimental/parallel/v2/task_region_pass.cpp295
-rw-r--r--libs/thread/test/sync/futures/async/async_pass.cpp44
-rw-r--r--libs/thread/test/sync/futures/future/async_deferred_then_pass.cpp23
-rw-r--r--libs/thread/test/sync/futures/future/get_or_pass.cpp87
-rw-r--r--libs/thread/test/sync/futures/make_ready_future_pass.cpp157
-rw-r--r--libs/thread/test/sync/futures/promise/emplace_pass.cpp207
-rw-r--r--libs/thread/test/sync/futures/shared_future/then_pass.cpp24
-rw-r--r--libs/thread/test/sync/mutual_exclusion/deque_views/single_thread_pass.cpp455
-rw-r--r--libs/thread/test/sync/mutual_exclusion/queue_views/single_thread_pass.cpp60
-rw-r--r--libs/thread/test/sync/mutual_exclusion/sync_deque/multi_thread_pass.cpp256
-rw-r--r--libs/thread/test/sync/mutual_exclusion/sync_deque/single_thread_pass.cpp403
-rw-r--r--libs/thread/test/sync/mutual_exclusion/sync_pq/pq_multi_thread_pass.cpp215
-rw-r--r--libs/thread/test/sync/mutual_exclusion/sync_pq/pq_single_thread_pass.cpp425
-rw-r--r--libs/thread/test/sync/mutual_exclusion/sync_pq/tq_single_thread_pass.cpp155
-rw-r--r--libs/thread/test/sync/mutual_exclusion/sync_queue/multi_thread_pass.cpp216
-rw-r--r--libs/thread/test/sync/mutual_exclusion/sync_queue/single_thread_pass.cpp440
-rw-r--r--libs/thread/test/sync/mutual_exclusion/with_lock_guard/with_lock_guard_bind.cpp2
-rw-r--r--libs/thread/test/test_10340.cpp5
-rw-r--r--libs/thread/test/test_10963.cpp44
-rw-r--r--libs/thread/test/test_10964.cpp76
-rw-r--r--libs/thread/test/test_11053.cpp70
-rwxr-xr-xlibs/thread/test/test_2309.cpp13
-rw-r--r--libs/thread/test/test_2741.cpp18
-rwxr-xr-xlibs/thread/test/test_9192.cpp5
-rw-r--r--libs/thread/test/test_9303.cpp7
-rw-r--r--libs/thread/test/test_9319.cpp21
-rw-r--r--libs/thread/test/test_9711.cpp4
-rw-r--r--libs/thread/test/test_9856.cpp29
-rw-r--r--libs/thread/test/test_condition.cpp18
-rw-r--r--libs/thread/test/test_condition_notify_all.cpp14
-rw-r--r--libs/thread/test/test_condition_notify_one.cpp16
-rw-r--r--libs/thread/test/test_condition_timed_wait_times_out.cpp14
-rw-r--r--libs/thread/test/test_futures.cpp173
-rw-r--r--libs/thread/test/test_generic_locks.cpp62
-rw-r--r--libs/thread/test/test_hardware_concurrency.cpp14
-rw-r--r--libs/thread/test/test_lock_concept.cpp64
-rw-r--r--libs/thread/test/test_move_function.cpp30
-rw-r--r--libs/thread/test/test_mutex.cpp29
-rw-r--r--libs/thread/test/test_once.cpp20
-rw-r--r--libs/thread/test/test_physical_concurrency.cpp12
-rw-r--r--libs/thread/test/test_scheduled_tp.cpp97
-rw-r--r--libs/thread/test/test_scheduler.cpp81
-rw-r--r--libs/thread/test/test_scheduling_adaptor.cpp54
-rw-r--r--libs/thread/test/test_shared_mutex.cpp27
-rw-r--r--libs/thread/test/test_shared_mutex_part_2.cpp35
-rw-r--r--libs/thread/test/test_shared_mutex_timed_locks.cpp33
-rw-r--r--libs/thread/test/test_shared_mutex_timed_locks_chrono.cpp32
-rw-r--r--libs/thread/test/test_thread.cpp36
-rw-r--r--libs/thread/test/test_thread_exit.cpp20
-rw-r--r--libs/thread/test/test_thread_id.cpp28
-rw-r--r--libs/thread/test/test_thread_launching.cpp36
-rw-r--r--libs/thread/test/test_thread_move.cpp20
-rw-r--r--libs/thread/test/test_thread_move_return.cpp13
-rw-r--r--libs/thread/test/test_thread_return_local.cpp15
-rw-r--r--libs/thread/test/test_tss.cpp68
-rw-r--r--libs/thread/test/test_xtime.cpp24
-rw-r--r--libs/thread/test/winrt_init.cpp2
59 files changed, 3645 insertions, 1296 deletions
diff --git a/libs/thread/test/Jamfile.v2 b/libs/thread/test/Jamfile.v2
index 37cc72c50..22f526501 100644
--- a/libs/thread/test/Jamfile.v2
+++ b/libs/thread/test/Jamfile.v2
@@ -34,6 +34,7 @@ project
<toolset>gcc:<cxxflags>-Wno-variadic-macros
#<toolset>gcc:<cxxflags>-Wunused-local-typedefs
<toolset>gcc:<cxxflags>-Wunused-function
+ <toolset>gcc:<cxxflags>-Wno-unused-parameter
<toolset>darwin:<cxxflags>-Wextra
<toolset>darwin:<cxxflags>-pedantic
@@ -43,18 +44,20 @@ project
<toolset>darwin:<cxxflags>-Wno-variadic-macros
#<toolset>darwin:<cxxflags>-Wunused-local-typedefs
<toolset>darwin:<cxxflags>-Wunused-function
+ <toolset>darwin:<cxxflags>-Wno-unused-parameter
#<toolset>pathscale:<cxxflags>-Wextra
<toolset>pathscale:<cxxflags>-Wno-long-long
<toolset>pathscale:<cxxflags>-pedantic
+ <toolset>clang:<warnings>on
<toolset>clang:<cxxflags>-Wextra
#<toolset>clang:<cxxflags>-pedantic
- <toolset>clang:<warnings>on
<toolset>clang:<cxxflags>-Wno-long-long
#<toolset>clang:<cxxflags>-ansi
#<toolset>clang:<cxxflags>-fpermissive # doesn't work
<toolset>clang:<cxxflags>-Wunused-function
+ <toolset>clang:<cxxflags>-Wno-unused-parameter
#<toolset>gcc-mingw-4.4.0:<cxxflags>-fdiagnostics-show-option
#<toolset>gcc-mingw-4.5.0:<cxxflags>-fdiagnostics-show-option
@@ -97,6 +100,10 @@ project
<toolset>intel:<cxxflags>-wd593,981
<toolset>intel:<cxxflags>-wd1418
<toolset>intel:<cxxflags>-wd2415
+
+ <toolset>msvc:<cxxflags>/wd4100
+ <toolset>msvc:<cxxflags>/wd4512
+ <toolset>msvc:<cxxflags>/wd6246
;
rule thread-run ( sources )
@@ -115,7 +122,7 @@ rule thread-test ( sources )
sources = $(sources) winrt_init.cpp ;
return
[ run $(sources) ../build//boost_thread : : :
- <library>/boost/test//boost_unit_test_framework/<link>static
+ <library>/boost/test//boost_unit_test_framework
]
[ run $(sources) ../src/tss_null.cpp ../build//boost_thread/<link>static
: : :
@@ -286,8 +293,11 @@ rule thread-compile ( sources : reqs * : name )
[ thread-run test_7328.cpp ]
[ thread-run test_7571.cpp ]
[ thread-run test_9319.cpp ]
- [ thread-run test_9711.cpp ]
-
+ #[ thread-run test_9711.cpp ] This is an invalid use of ::then deferred.
+ [ thread-run test_9856.cpp ]
+ [ thread-compile test_10963.cpp : : test_10963_c ]
+ [ thread-run test_10964.cpp ]
+ [ thread-test test_11053.cpp ]
;
@@ -349,6 +359,7 @@ rule thread-compile ( sources : reqs * : name )
[ thread-run2-noit ./sync/futures/promise/set_rvalue_pass.cpp : promise__set_rvalue_p ]
[ thread-run2-noit ./sync/futures/promise/set_value_const_pass.cpp : promise__set_value_const_p ]
[ thread-run2-noit ./sync/futures/promise/set_value_void_pass.cpp : promise__set_value_void_p ]
+ [ thread-run2-noit ./sync/futures/promise/emplace_pass.cpp : promise__emplace_p ]
[ thread-run2-noit ./sync/futures/promise/use_allocator_pass.cpp : promise__use_allocator_p ]
[ thread-run2-noit ./sync/futures/promise/set_exception_at_thread_exit_pass.cpp : promise__set_exception_at_thread_exit_p ]
[ thread-run2-noit ./sync/futures/promise/set_lvalue_at_thread_exit_pass.cpp : promise__set_lvalue_at_thread_exit_p ]
@@ -357,6 +368,12 @@ rule thread-compile ( sources : reqs * : name )
[ thread-run2-noit ./sync/futures/promise/set_value_at_thread_exit_void_pass.cpp : promise__set_value_at_thread_exit_void_p ]
;
+ #explicit ts_make_ready_future ;
+ test-suite ts_make_ready_future
+ :
+ [ thread-run2-noit ./sync/futures/make_ready_future_pass.cpp : make_ready_future_p ]
+ ;
+
#explicit ts_future ;
test-suite ts_future
:
@@ -669,18 +686,49 @@ rule thread-compile ( sources : reqs * : name )
[ thread-run2-noit ./sync/mutual_exclusion/sync_queue/multi_thread_pass.cpp : sync_queue__multi_thread_p ]
;
+ test-suite ts_sync_deque
+ :
+ [ thread-run2-noit ./sync/mutual_exclusion/sync_deque/single_thread_pass.cpp : sync_deque__single_thread_p ]
+ [ thread-run2-noit ./sync/mutual_exclusion/sync_deque/multi_thread_pass.cpp : sync_deque__multi_thread_p ]
+ ;
+
test-suite ts_sync_bounded_queue
:
[ thread-run2-noit ./sync/mutual_exclusion/sync_bounded_queue/single_thread_pass.cpp : sync_bounded_q_single_thread_p ]
[ thread-run2-noit ./sync/mutual_exclusion/sync_bounded_queue/multi_thread_pass.cpp : sync_bounded_q_multi_thread_p ]
;
+ test-suite ts_sync_pq
+ :
+ [ thread-run2-noit ./sync/mutual_exclusion/sync_pq/pq_single_thread_pass.cpp : sync_pq_single_thread_p ]
+ [ thread-run2-noit ./sync/mutual_exclusion/sync_pq/pq_multi_thread_pass.cpp : sync_pq_multi_thread_p ]
+ ;
+
+ test-suite ts_sync_tq
+ :
+ [ thread-run2-noit ./sync/mutual_exclusion/sync_pq/tq_single_thread_pass.cpp : sync_tq_single_thread_p ]
+ #[ thread-run2-noit ./sync/mutual_exclusion/sync_pq/tq_multi_thread_pass.cpp : sync_tq_multi_thread_p ]
+ ;
+
+ test-suite ts_scheduler
+ :
+ [ thread-run2-noit ./test_scheduled_tp.cpp : test_scheduled_tp_p ]
+ [ thread-run2-noit ./test_scheduling_adaptor.cpp : test_scheduling_adaptor_p ]
+ [ thread-run2-noit ./test_scheduler.cpp : test_scheduler_p ]
+ ;
+
test-suite ts_queue_views
:
[ thread-run2-noit ./sync/mutual_exclusion/queue_views/single_thread_pass.cpp : queue_views__single_thread_p ]
#[ thread-run2-noit ./sync/mutual_exclusion/queue_views/multi_thread_pass.cpp : queue_views__multi_thread_p ]
;
+ test-suite ts_deque_views
+ :
+ [ thread-run2-noit ./sync/mutual_exclusion/deque_views/single_thread_pass.cpp : deque_views__single_thread_p ]
+ #[ thread-run2-noit ./sync/mutual_exclusion/deque_views/multi_thread_pass.cpp : deque_views__multi_thread_p ]
+ ;
+
#explicit ts_this_thread ;
test-suite ts_this_thread
:
@@ -761,11 +809,13 @@ rule thread-compile ( sources : reqs * : name )
[ thread-run2 ../example/user_scheduler.cpp : ex_user_scheduler ]
[ thread-run2 ../example/executor.cpp : ex_executor ]
[ thread-run2 ../example/generic_executor_ref.cpp : ex_generic_executor_ref ]
+ [ thread-run2 ../example/serial_executor.cpp : ex_serial_executor ]
+ [ thread-run2 ../example/serial_executor_cont.cpp : ex_serial_executor_cont ]
[ thread-run2 ../example/future_when_all.cpp : ex_future_when_all ]
[ thread-run2 ../example/parallel_accumulate.cpp : ex_parallel_accumulate ]
[ thread-run2 ../example/parallel_quick_sort.cpp : ex_parallel_quick_sort ]
[ thread-run2 ../example/with_lock_guard.cpp : ex_with_lock_guard ]
-
+ [ thread-run2 ../example/fib_task_region.cpp : ex_fib_task_region ]
;
#explicit ts_shared_upwards ;
@@ -883,10 +933,25 @@ rule thread-compile ( sources : reqs * : name )
#[ thread-run ../example/perf_condition_variable.cpp ]
#[ thread-run ../example/perf_shared_mutex.cpp ]
;
+
+
+ #explicit ts_exception_list ;
+ test-suite ts_exception_list
+ :
+ [ thread-run2-noit ./experimental/parallel/v1/exception_list_pass.cpp : exception_list_p ]
+ ;
+
+ #explicit ts_task_region ;
+ test-suite ts_task_region
+ :
+ [ thread-run2-noit ./experimental/parallel/v2/task_region_pass.cpp : task_region_p ]
+ ;
explicit ts_ ;
test-suite ts_
:
+ [ thread-run2 ../example/this_executor.cpp : ex_this_executor ]
+ [ thread-run2 ../example/default_executor.cpp : ex_default_executor ]
;
}
diff --git a/libs/thread/test/experimental/parallel/v1/exception_list_pass.cpp b/libs/thread/test/experimental/parallel/v1/exception_list_pass.cpp
new file mode 100644
index 000000000..de79412ae
--- /dev/null
+++ b/libs/thread/test/experimental/parallel/v1/exception_list_pass.cpp
@@ -0,0 +1,23 @@
+// Copyright (C) 2014 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/experimental/parallel/v1/exception_list.hpp>
+
+
+#define BOOST_THREAD_VERSION 4
+#include <boost/config.hpp>
+#if ! defined BOOST_NO_CXX11_DECLTYPE
+#define BOOST_RESULT_OF_USE_DECLTYPE
+#endif
+
+#include <boost/thread/experimental/parallel/v1/exception_list.hpp>
+
+#include <boost/detail/lightweight_test.hpp>
+
+
+int main()
+{
+ return boost::report_errors();
+}
diff --git a/libs/thread/test/experimental/parallel/v2/task_region_pass.cpp b/libs/thread/test/experimental/parallel/v2/task_region_pass.cpp
new file mode 100644
index 000000000..814ef28e5
--- /dev/null
+++ b/libs/thread/test/experimental/parallel/v2/task_region_pass.cpp
@@ -0,0 +1,295 @@
+// Copyright (C) 2014-2015 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/experimental/parallel/v1/exception_list.hpp>
+
+
+#define BOOST_THREAD_VERSION 4
+#define BOOST_THREAD_PROVIDES_EXECUTORS
+#include <boost/config.hpp>
+#if ! defined BOOST_NO_CXX11_DECLTYPE
+#define BOOST_RESULT_OF_USE_DECLTYPE
+#endif
+
+#include <boost/thread/experimental/parallel/v2/task_region.hpp>
+#include <string>
+
+#include <boost/detail/lightweight_test.hpp>
+
+#if ! defined BOOST_NO_CXX11_LAMBDAS && defined(BOOST_THREAD_PROVIDES_INVOKE)
+using boost::experimental::parallel::v2::task_region;
+using boost::experimental::parallel::v2::task_region_handle;
+using boost::experimental::parallel::v1::exception_list;
+
+void run_no_exception()
+{
+ std::string s("test");
+ bool parent_flag = false;
+ bool task1_flag = false;
+ bool task2_flag = false;
+ bool task21_flag = false;
+ bool task3_flag = false;
+ task_region([&](task_region_handle& trh)
+ {
+ parent_flag = true;
+ trh.run([&]()
+ {
+ task1_flag = true;
+ std::cout << "task1: " << s << std::endl;
+ });
+ trh.run([&]()
+ {
+ task2_flag = true;
+ std::cout << "task2" << std::endl;
+ task_region([&](task_region_handle& trh)
+ {
+ trh.run([&]()
+ {
+ task21_flag = true;
+ std::cout << "task2.1" << std::endl;
+ });
+ });
+ });
+ int i = 0, j = 10, k = 20;
+ trh.run([=, &task3_flag]()
+ {
+ task3_flag = true;
+ std::cout << "task3: " << i << " " << j << " " << k << std::endl;
+ });
+ std::cout << "parent" << std::endl;
+ });
+ BOOST_TEST(parent_flag);
+ BOOST_TEST(task1_flag);
+ BOOST_TEST(task2_flag);
+ BOOST_TEST(task21_flag);
+ BOOST_TEST(task3_flag);
+}
+
+void run_no_exception_wait()
+{
+ std::string s("test");
+ bool parent_flag = false;
+ bool wait_flag = false;
+ bool task1_flag = false;
+ bool task2_flag = false;
+ bool task21_flag = false;
+ bool task3_flag = false;
+ task_region([&](task_region_handle& trh)
+ {
+ parent_flag = true;
+ trh.run([&]()
+ {
+ task1_flag = true;
+ std::cout << "task1: " << s << std::endl;
+ });
+ trh.run([&]()
+ {
+ task2_flag = true;
+ std::cout << "task2" << std::endl;
+ task_region([&](task_region_handle& trh)
+ {
+ trh.run([&]()
+ {
+ task21_flag = true;
+ std::cout << "task2.1" << std::endl;
+ });
+ });
+ });
+ int i = 0, j = 10, k = 20;
+ trh.run([=, &task3_flag]()
+ {
+ task3_flag = true;
+ std::cout << "task3: " << i << " " << j << " " << k << std::endl;
+ });
+ std::cout << "before" << std::endl;
+ trh.wait();
+ wait_flag = true;
+ std::cout << "parent" << std::endl;
+ });
+ BOOST_TEST(parent_flag);
+ BOOST_TEST(wait_flag);
+ BOOST_TEST(task1_flag);
+ BOOST_TEST(task2_flag);
+ BOOST_TEST(task21_flag);
+ BOOST_TEST(task3_flag);
+}
+
+void run_exception_1()
+{
+ try
+ {
+ task_region([](task_region_handle& trh)
+ {
+ trh.run([]()
+ {
+ std::cout << "task1" << std::endl;
+ throw 1;
+ });
+ boost::this_thread::sleep_for(boost::chrono::seconds(1));
+ trh.run([]()
+ {
+ std::cout << "task3" << std::endl;
+ });
+#if defined BOOST_THREAD_TASK_REGION_HAS_SHARED_CANCELED
+ BOOST_TEST(false);
+#endif
+ });
+ BOOST_TEST(false);
+ }
+ catch (exception_list const& e)
+ {
+ BOOST_TEST_EQ(e.size(), 1u);
+ }
+ catch (...)
+ {
+ BOOST_TEST(false);
+ }
+}
+
+void run_exception()
+{
+ try
+ {
+ task_region([](task_region_handle& trh)
+ {
+ trh.run([]()
+ {
+ std::cout << "task1" << std::endl;
+ throw 1;
+ });
+ trh.run([]()
+ {
+ std::cout << "task2" << std::endl;
+ throw 2;
+ });
+ boost::this_thread::sleep_for(boost::chrono::seconds(1));
+ trh.run([]()
+ {
+ std::cout << "task3" << std::endl;
+ throw 3;
+ });
+ std::cout << "parent" << std::endl;
+ throw 100;
+ });
+ BOOST_TEST(false);
+ }
+ catch (exception_list const& el)
+ {
+ BOOST_TEST(el.size() >= 1u);
+ for (boost::exception_ptr const& e: el)
+ {
+ try {
+ boost::rethrow_exception(e);
+ }
+ catch (boost::exception&)
+ {
+ BOOST_TEST(true);
+ }
+ catch (int i) // this doesn't works yet
+ {
+ BOOST_TEST((i == 1) || (i == 2) || (i == 3));
+ }
+ catch (...)
+ {
+ BOOST_TEST(false);
+ }
+ }
+ }
+ catch (...)
+ {
+ BOOST_TEST(false);
+ }
+}
+
+
+void run_nested_exception()
+{
+ std::string s("test");
+ bool parent_flag = false;
+ bool task1_flag = false;
+ bool task2_flag = false;
+ bool task21_flag = false;
+ bool task3_flag = false;
+ try
+ {
+ task_region([&](task_region_handle& trh)
+ {
+ parent_flag = true;
+ trh.run([&]()
+ {
+ task1_flag = true;
+ std::cout << "task1: " << s << std::endl;
+ });
+ trh.run([&]()
+ {
+ task2_flag = true;
+ std::cout << "task2" << std::endl;
+ task_region([&](task_region_handle& trh)
+ {
+ trh.run([&]()
+ {
+ task21_flag = true;
+ std::cout << "task2.1" << std::endl;
+ throw 21;
+ });
+ });
+ });
+ int i = 0, j = 10, k = 20;
+ trh.run([=, &task3_flag]()
+ {
+ task3_flag = true;
+ std::cout << "task3: " << i << " " << j << " " << k << std::endl;
+ });
+ std::cout << "parent" << std::endl;
+ });
+ }
+ catch (exception_list const& el)
+ {
+ BOOST_TEST(el.size() == 1u);
+ for (boost::exception_ptr const& e: el)
+ {
+ try {
+ boost::rethrow_exception(e);
+ }
+ catch (int i) // this doesn't works yet
+ {
+ BOOST_TEST_EQ(i, 21);
+ }
+ catch (boost::exception&)
+ {
+ BOOST_TEST(true);
+ }
+ catch (...)
+ {
+ BOOST_TEST(false);
+ }
+ }
+ }
+ catch (...)
+ {
+ BOOST_TEST(false);
+ }
+ BOOST_TEST(parent_flag);
+ BOOST_TEST(task1_flag);
+ BOOST_TEST(task2_flag);
+ BOOST_TEST(task21_flag);
+}
+
+
+int main()
+{
+ run_no_exception();
+ run_no_exception_wait();
+ run_exception();
+ run_exception_1();
+ run_nested_exception();
+ return boost::report_errors();
+}
+#else
+int main()
+{
+ return boost::report_errors();
+}
+#endif
diff --git a/libs/thread/test/sync/futures/async/async_pass.cpp b/libs/thread/test/sync/futures/async/async_pass.cpp
index add6282cf..86fdfdbec 100644
--- a/libs/thread/test/sync/futures/async/async_pass.cpp
+++ b/libs/thread/test/sync/futures/async/async_pass.cpp
@@ -85,7 +85,7 @@ public:
return *this;
}
- int operator()()
+ int operator()() const
{
boost::this_thread::sleep_for(ms(200));
return 3;
@@ -167,6 +167,48 @@ struct check_timer {
int main()
{
+ {
+ try {
+ boost::async(f0);
+ } catch (std::exception& ex)
+ {
+ std::cout << __FILE__ << "[" << __LINE__ << "]" << ex.what() << std::endl;
+ BOOST_TEST(false && "exception thrown");
+ }
+ catch (...)
+ {
+ BOOST_TEST(false && "exception thrown");
+ }
+ }
+ {
+ try {
+ boost::async(boost::launch::async, f0);
+ } catch (std::exception& ex)
+ {
+ std::cout << __FILE__ << "[" << __LINE__ << "]" << ex.what() << std::endl;
+ BOOST_TEST(false && "exception thrown");
+ }
+ catch (...)
+ {
+ BOOST_TEST(false && "exception thrown");
+ }
+ }
+#if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
+ std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
+ {
+ try {
+ boost::async(boost::launch::deferred, f0);
+ } catch (std::exception& ex)
+ {
+ std::cout << __FILE__ << "[" << __LINE__ << "]" << ex.what() << std::endl;
+ BOOST_TEST(false && "exception thrown");
+ }
+ catch (...)
+ {
+ BOOST_TEST(false && "exception thrown");
+ }
+ }
+#endif
std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
{
try
diff --git a/libs/thread/test/sync/futures/future/async_deferred_then_pass.cpp b/libs/thread/test/sync/futures/future/async_deferred_then_pass.cpp
index e17e912ce..b400074cd 100644
--- a/libs/thread/test/sync/futures/future/async_deferred_then_pass.cpp
+++ b/libs/thread/test/sync/futures/future/async_deferred_then_pass.cpp
@@ -53,6 +53,29 @@ int main()
{
BOOST_THREAD_LOG << BOOST_THREAD_END_LOG;
{
+ try
+ {
+ boost::future<int> f1 = boost::async(boost::launch::deferred, &p1);
+ BOOST_TEST(f1.valid());
+ {
+ boost::future<int> f2 = f1.then(&p2);
+ BOOST_TEST(f2.valid());
+ }
+ BOOST_TEST(! f1.valid());
+ }
+ catch (std::exception& ex)
+ {
+ BOOST_THREAD_LOG << "ERRORRRRR "<<ex.what() << "" << BOOST_THREAD_END_LOG;
+ BOOST_TEST(false);
+ }
+ catch (...)
+ {
+ BOOST_THREAD_LOG << " ERRORRRRR exception thrown" << BOOST_THREAD_END_LOG;
+ BOOST_TEST(false);
+ }
+ }
+ BOOST_THREAD_LOG << BOOST_THREAD_END_LOG;
+ {
boost::future<int> f1 = boost::async(boost::launch::deferred, &p1);
BOOST_TEST(f1.valid());
boost::future<int> f2 = f1.then(&p2);
diff --git a/libs/thread/test/sync/futures/future/get_or_pass.cpp b/libs/thread/test/sync/futures/future/get_or_pass.cpp
index a2bd65222..64409455b 100644
--- a/libs/thread/test/sync/futures/future/get_or_pass.cpp
+++ b/libs/thread/test/sync/futures/future/get_or_pass.cpp
@@ -17,6 +17,7 @@
#include <boost/thread/future.hpp>
#include <boost/thread/thread.hpp>
+#include <boost/core/ref.hpp>
#include <boost/detail/lightweight_test.hpp>
#if defined BOOST_THREAD_USES_CHRONO
@@ -128,49 +129,49 @@ int main()
BOOST_THREAD_LOG << BOOST_THREAD_END_LOG;
}
}
-// BOOST_THREAD_LOG << BOOST_THREAD_END_LOG;
-// {
-// typedef int& T;
-// {
-// boost::promise<T> p;
-// boost::future<T> f = p.get_future();
-//#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
-// boost::thread(func3, boost::move(p)).detach();
-//#else
-// int j=5;
-// p.set_value(j);
-//#endif
-// BOOST_TEST(f.valid());
-// int k=4;
-// BOOST_TEST(f.get_or(k) == 5);
-//#ifdef BOOST_THREAD_PROVIDES_FUTURE_INVALID_AFTER_GET
-// BOOST_TEST(!f.valid());
-//#endif
-// }
-// BOOST_THREAD_LOG << BOOST_THREAD_END_LOG;
-// {
-// boost::promise<T> p;
-// boost::future<T> f = p.get_future();
-//#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
-// boost::thread(func4, boost::move(p)).detach();
-//#else
-// p.set_exception(boost::make_exception_ptr(3.5));
-//#endif
-// try
-// {
-// BOOST_TEST(f.valid());
-// int j=4;
-// BOOST_TEST(f.get_or(j) == 4);
-// }
-// catch (...)
-// {
-// BOOST_TEST(false);
-// }
-//#ifdef BOOST_THREAD_PROVIDES_FUTURE_INVALID_AFTER_GET
-// BOOST_TEST(!f.valid());
-//#endif
-// }
-// }
+ BOOST_THREAD_LOG << BOOST_THREAD_END_LOG;
+ {
+ typedef int& T;
+ {
+ boost::promise<T> p;
+ boost::future<T> f = p.get_future();
+#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
+ boost::thread(func3, boost::move(p)).detach();
+#else
+ int j=5;
+ p.set_value(j);
+#endif
+ BOOST_TEST(f.valid());
+ int k=4;
+ BOOST_TEST(f.get_or(boost::ref(k)) == 5);
+#ifdef BOOST_THREAD_PROVIDES_FUTURE_INVALID_AFTER_GET
+ BOOST_TEST(!f.valid());
+#endif
+ }
+ BOOST_THREAD_LOG << BOOST_THREAD_END_LOG;
+ {
+ boost::promise<T> p;
+ boost::future<T> f = p.get_future();
+#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
+ boost::thread(func4, boost::move(p)).detach();
+#else
+ p.set_exception(boost::make_exception_ptr(3.5));
+#endif
+ try
+ {
+ BOOST_TEST(f.valid());
+ int j=4;
+ BOOST_TEST(f.get_or(boost::ref(j)) == 4);
+ }
+ catch (...)
+ {
+ BOOST_TEST(false);
+ }
+#ifdef BOOST_THREAD_PROVIDES_FUTURE_INVALID_AFTER_GET
+ BOOST_TEST(!f.valid());
+#endif
+ }
+ }
BOOST_THREAD_LOG << BOOST_THREAD_END_LOG;
diff --git a/libs/thread/test/sync/futures/make_ready_future_pass.cpp b/libs/thread/test/sync/futures/make_ready_future_pass.cpp
new file mode 100644
index 000000000..dfce3cde7
--- /dev/null
+++ b/libs/thread/test/sync/futures/make_ready_future_pass.cpp
@@ -0,0 +1,157 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (C) 2011,2014 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/future.hpp>
+
+// class promise<R>
+
+// future<void> make_ready_future();
+// template <class T>
+// future<decay_t<T>> make_ready_future(T&&);
+// template <class T>
+// future<T> make_ready_future(remove_reference_t<T>&);
+// template <class T>
+// future<T> make_ready_future(remove_reference_t<T>&&);
+// template <class T, class ...Args>
+// future<T> make_ready_future(Args&& ... args);
+
+#define BOOST_THREAD_VERSION 3
+
+#include <boost/thread/future.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/static_assert.hpp>
+
+struct A
+{
+ A() :
+ value(0)
+ {
+ }
+ A(int i) :
+ value(i)
+ {
+ }
+ A(int i, int j) :
+ value(i+j)
+ {
+ }
+ int value;
+};
+
+A make(int i) {
+ return A(i);
+}
+A make(int i, int j) {
+ return A(i, j);
+}
+
+struct movable2
+{
+ int value_;
+ BOOST_THREAD_MOVABLE_ONLY(movable2)
+ movable2() : value_(1){}
+ movable2(int i) : value_(i){}
+ movable2(int i, int j) : value_(i+j){}
+
+ //Move constructor and assignment
+ movable2(BOOST_RV_REF(movable2) m)
+ { value_ = m.value_; m.value_ = 0; }
+
+ movable2 & operator=(BOOST_THREAD_RV_REF(movable2) m)
+ { value_ = m.value_; m.value_ = 0; return *this; }
+
+ bool moved() const //Observer
+ { return !value_; }
+
+ int value() const //Observer
+ { return value_; }
+};
+
+
+movable2 move_return_function2(int i) {
+ return movable2(i);
+}
+
+int main()
+{
+#if defined BOOST_NO_CXX11_RVALUE_REFERENCES
+ BOOST_STATIC_ASSERT((boost::is_copy_constructible<movable2>::value == false));
+ BOOST_STATIC_ASSERT((boost::has_move_emulation_enabled<movable2>::value == true));
+ BOOST_STATIC_ASSERT((boost::is_copy_constructible<A>::value == true));
+ BOOST_STATIC_ASSERT((boost::has_move_emulation_enabled<A>::value == false));
+#endif
+
+ {
+ boost::future<void> f = boost::make_ready_future();
+ f.wait();
+ }
+ {
+ typedef A T;
+ T i;
+ boost::future<T> f = boost::make_ready_future(i);
+ BOOST_TEST(f.get().value==0);
+ }
+#if ! defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
+ {
+ typedef A T;
+ boost::future<T> f = boost::make_ready_future<T>();
+ BOOST_TEST(f.get().value==0);
+ }
+ {
+ typedef A T;
+ boost::future<T> f = boost::make_ready_future<T>(1);
+ BOOST_TEST(f.get().value==1);
+ }
+ {
+ typedef A T;
+ boost::future<T> f = boost::make_ready_future<T>(1,2);
+ BOOST_TEST(f.get().value==3);
+ }
+ {
+ typedef A T;
+ T i;
+ boost::future<T&> f = boost::make_ready_future<T&>(i);
+ BOOST_TEST(f.get().value==0);
+ }
+#endif
+#if ! defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
+// sync/futures/make_ready_future_pass.cpp:125:65: erreur: conversion from Ôboost::future<boost::rv<movable2> >Õ to non-scalar type Ôboost::future<movable2>Õ requested
+ {
+ typedef movable2 T;
+ T i;
+ boost::future<T> f = boost::make_ready_future(boost::move(i));
+ BOOST_TEST_EQ(f.get().value(),1);
+ }
+#endif
+#if ! defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
+ {
+ typedef movable2 T;
+ boost::future<T> f = boost::make_ready_future<T>();
+ BOOST_TEST(f.get().value()==1);
+ }
+ {
+ typedef movable2 T;
+ boost::future<T> f = boost::make_ready_future<T>(1);
+ BOOST_TEST(f.get().value()==1);
+ }
+ {
+ typedef movable2 T;
+ boost::future<T> f = boost::make_ready_future<T>(1,2);
+ BOOST_TEST(f.get().value()==3);
+ }
+#endif
+
+ return boost::report_errors();
+}
+
diff --git a/libs/thread/test/sync/futures/promise/emplace_pass.cpp b/libs/thread/test/sync/futures/promise/emplace_pass.cpp
new file mode 100644
index 000000000..6a1a35292
--- /dev/null
+++ b/libs/thread/test/sync/futures/promise/emplace_pass.cpp
@@ -0,0 +1,207 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Copyright (C) 2011,2014 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/future.hpp>
+
+// class promise<R>
+
+// template <class ...Args>
+// void promise::emplace(Args&& ... args);
+
+#define BOOST_THREAD_VERSION 3
+
+#include <boost/thread/future.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/static_assert.hpp>
+
+struct A
+{
+ A() :
+ value(0)
+ {
+ }
+ A(int i) :
+ value(i)
+ {
+ }
+ A(int i, int j) :
+ value(i+j)
+ {
+ }
+ BOOST_THREAD_MOVABLE_ONLY(A)
+
+ A(BOOST_THREAD_RV_REF(A) rhs)
+ {
+ if(rhs.value==0)
+ throw 9;
+ else
+ {
+ value=rhs.value;
+ rhs.value=0;
+ }
+ }
+ A& operator=(BOOST_THREAD_RV_REF(A) rhs)
+ {
+ if(rhs.value==0)
+ throw 9;
+ else
+ {
+ value=rhs.value;
+ rhs.value=0;
+ }
+ return *this;
+ }
+ int value;
+};
+
+A make(int i) {
+ return A(i);
+}
+A make(int i, int j) {
+ return A(i, j);
+}
+
+struct movable2
+{
+ int value_;
+ BOOST_THREAD_MOVABLE_ONLY(movable2)
+ movable2() : value_(1){}
+ movable2(int i) : value_(i){}
+ movable2(int i, int j) : value_(i+j){}
+
+ //Move constructor and assignment
+ movable2(BOOST_RV_REF(movable2) m)
+ { value_ = m.value_; m.value_ = 0; }
+
+ movable2 & operator=(BOOST_THREAD_RV_REF(movable2) m)
+ { value_ = m.value_; m.value_ = 0; return *this; }
+
+ bool moved() const //Observer
+ { return !value_; }
+
+ int value() const //Observer
+ { return value_; }
+};
+
+
+movable2 move_return_function2(int i) {
+ return movable2(i);
+}
+
+int main()
+{
+#if defined BOOST_NO_CXX11_RVALUE_REFERENCES
+ BOOST_STATIC_ASSERT((boost::is_copy_constructible<movable2>::value == false));
+ BOOST_STATIC_ASSERT((boost::has_move_emulation_enabled<movable2>::value == true));
+ BOOST_STATIC_ASSERT((boost::is_copy_constructible<A>::value == false));
+ BOOST_STATIC_ASSERT((boost::has_move_emulation_enabled<A>::value == true));
+#endif
+#if ! defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
+
+ {
+ typedef A T;
+ T i;
+ boost::promise<T> p;
+ boost::future<T> f = p.get_future();
+ p.emplace();
+ try
+ {
+ T a = f.get(); (void)a;
+ BOOST_TEST(false);
+ }
+ catch (int j)
+ {
+ BOOST_TEST(j == 9);
+ }
+ catch (...)
+ {
+ BOOST_TEST(false);
+ }
+ }
+ {
+ typedef A T;
+ boost::promise<T> p;
+ boost::future<T> f = p.get_future();
+ p.emplace(3);
+ BOOST_TEST(f.get().value == 3);
+ try
+ {
+ T j(3);
+ p.set_value(boost::move(j));
+ BOOST_TEST(false);
+ }
+ catch (const boost::future_error& e)
+ {
+ BOOST_TEST(e.code() == boost::system::make_error_code(boost::future_errc::promise_already_satisfied));
+ }
+ catch (...)
+ {
+ BOOST_TEST(false);
+ }
+
+ }
+ {
+ boost::promise<movable2> p;
+ boost::future<movable2> f = p.get_future();
+ p.emplace(3);
+ BOOST_TEST(f.get().value_ == 3);
+ try
+ {
+ p.emplace(3);
+ BOOST_TEST(false);
+ }
+ catch (const boost::future_error& e)
+ {
+ BOOST_TEST(e.code() == boost::system::make_error_code(boost::future_errc::promise_already_satisfied));
+ }
+ catch (...)
+ {
+ BOOST_TEST(false);
+ }
+
+ }
+ {
+ boost::promise<A> p;
+ boost::future<A> f = p.get_future();
+ p.emplace(1,2);
+ BOOST_TEST(f.get().value == 3);
+ try
+ {
+ p.emplace(1,2);
+ BOOST_TEST(false);
+ }
+ catch (const boost::future_error& e)
+ {
+ BOOST_TEST(e.code() == boost::system::make_error_code(boost::future_errc::promise_already_satisfied));
+ }
+ catch (...)
+ {
+ BOOST_TEST(false);
+ }
+
+ }
+ {
+ typedef A T;
+ boost::promise<T> p;
+ boost::future<T> f = p.get_future();
+ p.emplace(3);
+ boost::promise<T> p2(boost::move(p));
+ BOOST_TEST(f.get().value == 3);
+
+ }
+#endif
+
+ return boost::report_errors();
+}
+
diff --git a/libs/thread/test/sync/futures/shared_future/then_pass.cpp b/libs/thread/test/sync/futures/shared_future/then_pass.cpp
index 4739135bf..b7d95bc66 100644
--- a/libs/thread/test/sync/futures/shared_future/then_pass.cpp
+++ b/libs/thread/test/sync/futures/shared_future/then_pass.cpp
@@ -75,6 +75,30 @@ int main()
{
boost::shared_future<int> f1 = boost::async(boost::launch::async, &p1).share();
BOOST_TEST(f1.valid());
+ boost::future<int> f2 = f1.then(&p2);
+ boost::future<int> f3 = f1.then(&p2);
+ BOOST_TEST(f2.valid());
+ BOOST_TEST(f3.valid());
+ try
+ {
+ BOOST_TEST(f2.get()==2);
+ BOOST_TEST(f3.get()==2);
+ }
+ catch (std::exception& ex)
+ {
+ BOOST_THREAD_LOG << "ERRORRRRR "<<ex.what() << "" << BOOST_THREAD_END_LOG;
+ BOOST_TEST(false);
+ }
+ catch (...)
+ {
+ BOOST_THREAD_LOG << " ERRORRRRR exception thrown" << BOOST_THREAD_END_LOG;
+ BOOST_TEST(false);
+ }
+ }
+ BOOST_THREAD_LOG << BOOST_THREAD_END_LOG;
+ {
+ boost::shared_future<int> f1 = boost::async(boost::launch::async, &p1).share();
+ BOOST_TEST(f1.valid());
boost::future<void> f2 = f1.then(&p3);
BOOST_TEST(f2.valid());
try
diff --git a/libs/thread/test/sync/mutual_exclusion/deque_views/single_thread_pass.cpp b/libs/thread/test/sync/mutual_exclusion/deque_views/single_thread_pass.cpp
new file mode 100644
index 000000000..96e8e268d
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/deque_views/single_thread_pass.cpp
@@ -0,0 +1,455 @@
+// Copyright (C) 2014 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/sync_deque.hpp>
+
+// class sync_deque<T>
+
+// sync_deque();
+
+#define BOOST_THREAD_VERSION 4
+//#define BOOST_THREAD_QUEUE_DEPRECATE_OLD
+
+#include <boost/thread/concurrent_queues/sync_deque.hpp>
+#include <boost/thread/concurrent_queues/deque_adaptor.hpp>
+#include <boost/thread/concurrent_queues/deque_views.hpp>
+
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/static_assert.hpp>
+
+class non_copyable
+{
+ BOOST_THREAD_MOVABLE_ONLY(non_copyable)
+ int val;
+public:
+ non_copyable(int v) : val(v){}
+ non_copyable(BOOST_RV_REF(non_copyable) x): val(x.val) {}
+ non_copyable& operator=(BOOST_RV_REF(non_copyable) x) { val=x.val; return *this; }
+ bool operator==(non_copyable const& x) const {return val==x.val;}
+ template <typename OSTREAM>
+ friend OSTREAM& operator <<(OSTREAM& os, non_copyable const&x )
+ {
+ os << x.val;
+ return os;
+ }
+
+};
+
+#if defined BOOST_NO_CXX11_RVALUE_REFERENCES
+BOOST_STATIC_ASSERT( ! boost::is_copy_constructible<non_copyable>::value );
+BOOST_STATIC_ASSERT( boost::has_move_emulation_enabled<non_copyable>::value );
+#endif
+
+int main()
+{
+
+ {
+ // default queue invariants
+ boost::deque_adaptor<boost::sync_deque<int> > sq;
+ boost::deque_back<int> q(sq);
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(! q.closed());
+ }
+ {
+ // default queue invariants
+ boost::deque_adaptor<boost::sync_deque<int> > sq;
+ boost::deque_front<int> q(sq);
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(! q.closed());
+ }
+
+
+ {
+ // empty queue try_pull fails
+ boost::deque_adaptor<boost::sync_deque<int> > sq;
+ boost::deque_front<int> q(sq);
+ int i;
+ BOOST_TEST( boost::queue_op_status::empty == q.try_pull(i));
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(! q.closed());
+ }
+ {
+ // empty queue push rvalue/copyable succeeds
+ boost::deque_adaptor<boost::sync_deque<int> > sq;
+ boost::deque_back<int> q(sq);
+ q.push(1);
+ BOOST_TEST(! q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 1u);
+ BOOST_TEST(! q.closed());
+ }
+ {
+ // empty queue push lvalue/copyable succeeds
+ boost::deque_adaptor<boost::sync_deque<int> > sq;
+ boost::deque_back<int> q(sq);
+ int i;
+ q.push(i);
+ BOOST_TEST(! q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 1u);
+ BOOST_TEST(! q.closed());
+ }
+
+
+#if 0
+ {
+ // empty queue push rvalue/non_copyable succeeds
+ boost::deque_adaptor<boost::sync_deque<non_copyable> > sq;
+ boost::deque_back<non_copyable> q(sq);
+ q.push(non_copyable(1));
+ BOOST_TEST(! q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 1u);
+ BOOST_TEST(! q.closed());
+ }
+#endif
+ {
+ // empty queue push rvalue/non_copyable succeeds
+ boost::deque_adaptor<boost::sync_deque<non_copyable> > q;
+ //boost::sync_deque<non_copyable> q;
+ //boost::deque_back<non_copyable> q(sq);
+ non_copyable nc(1);
+ q.push_back(boost::move(nc));
+ BOOST_TEST(! q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 1u);
+ BOOST_TEST(! q.closed());
+ }
+
+ {
+ // empty queue push rvalue succeeds
+ boost::deque_adaptor<boost::sync_deque<int> > sq;
+ boost::deque_back<int> q(sq);
+ q.push(1);
+ q.push(2);
+ BOOST_TEST(! q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 2u);
+ BOOST_TEST(! q.closed());
+ }
+ {
+ // empty queue push lvalue succeeds
+ boost::deque_adaptor<boost::sync_deque<int> > sq;
+ boost::deque_back<int> q(sq);
+ int i;
+ q.push(i);
+ BOOST_TEST(! q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 1u);
+ BOOST_TEST(! q.closed());
+ }
+ {
+ // empty queue try_push rvalue/copyable succeeds
+ boost::deque_adaptor<boost::sync_deque<int> > sq;
+ boost::deque_back<int> q(sq);
+ BOOST_TEST(boost::queue_op_status::success == q.try_push(1));
+ BOOST_TEST(! q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 1u);
+ BOOST_TEST(! q.closed());
+ }
+ {
+ // empty queue try_push rvalue/copyable succeeds
+ boost::deque_adaptor<boost::sync_deque<int> > sq;
+ boost::deque_back<int> q(sq);
+ BOOST_TEST(boost::queue_op_status::success == q.try_push(1));
+ BOOST_TEST(! q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 1u);
+ BOOST_TEST(! q.closed());
+ }
+
+#if 0
+ {
+ // empty queue try_push rvalue/non-copyable succeeds
+ boost::deque_adaptor<boost::sync_deque<non_copyable> > sq;
+ boost::deque_back<non_copyable> q(sq);
+ non_copyable nc(1);
+ BOOST_TEST(boost::queue_op_status::success == q.try_push(boost::move(nc)));
+ BOOST_TEST(! q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 1u);
+ BOOST_TEST(! q.closed());
+ }
+#endif
+
+ {
+ // empty queue try_push lvalue succeeds
+ boost::deque_adaptor<boost::sync_deque<int> > sq;
+ boost::deque_back<int> q(sq);
+ int i;
+ BOOST_TEST(boost::queue_op_status::success == q.try_push(i));
+ BOOST_TEST(! q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 1u);
+ BOOST_TEST(! q.closed());
+ }
+ {
+ // empty queue try_push rvalue succeeds
+ boost::deque_adaptor<boost::sync_deque<int> > sq;
+ boost::deque_back<int> q(sq);
+ 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 0
+ {
+ // empty queue nonblocking_push_back rvalue/non-copyable succeeds
+ boost::deque_adaptor<boost::sync_deque<non_copyable> > sq;
+ boost::deque_back<non_copyable> q(sq);
+ BOOST_TEST(boost::queue_op_status::success == q.nonblocking_push(non_copyable(1)));
+ BOOST_TEST(! q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 1u);
+ BOOST_TEST(! q.closed());
+ }
+#endif
+ {
+ // empty queue nonblocking_push_back rvalue/non-copyable succeeds
+ boost::deque_adaptor<boost::sync_deque<non_copyable> > sq;
+ boost::deque_back<non_copyable> q(sq);
+ 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());
+ }
+ {
+ // 1-element queue pull_front succeed
+ boost::deque_adaptor<boost::sync_deque<int> > sq;
+ boost::deque_front<int> q(sq);
+ sq.push_back(1);
+ int i;
+ q.pull(i);
+ BOOST_TEST_EQ(i, 1);
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(! q.closed());
+ }
+ {
+ // 1-element queue pull_front succeed
+ boost::deque_adaptor<boost::sync_deque<non_copyable> > sq;
+ boost::deque_front<non_copyable> q(sq);
+ non_copyable nc1(1);
+ sq.push_back(boost::move(nc1));
+ non_copyable nc2(2);
+ q.pull(nc2);
+ BOOST_TEST_EQ(nc1, nc2);
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(! q.closed());
+ }
+ {
+ // 1-element queue pull_front succeed
+ boost::deque_adaptor<boost::sync_deque<int> > sq;
+ boost::deque_front<int> q(sq);
+ sq.push_back(1);
+ int i = q.pull();
+ BOOST_TEST_EQ(i, 1);
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(! q.closed());
+ }
+ {
+ // 1-element queue pull_front succeed
+ boost::deque_adaptor<boost::sync_deque<non_copyable> > sq;
+ boost::deque_front<non_copyable> q(sq);
+ non_copyable nc1(1);
+ sq.push_back(boost::move(nc1));
+ non_copyable nc = q.pull();
+ BOOST_TEST_EQ(nc, nc1);
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(! q.closed());
+ }
+ {
+ // 1-element queue try_pull_front succeed
+ boost::deque_adaptor<boost::sync_deque<int> > sq;
+ boost::deque_front<int> q(sq);
+ sq.push_back(1);
+ int i;
+ BOOST_TEST(boost::queue_op_status::success == q.try_pull(i));
+ BOOST_TEST_EQ(i, 1);
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(! q.closed());
+ }
+ {
+ // 1-element queue try_pull_front succeed
+ boost::deque_adaptor<boost::sync_deque<non_copyable> > sq;
+ boost::deque_front<non_copyable> q(sq);
+ non_copyable nc1(1);
+ sq.push_back(boost::move(nc1));
+ non_copyable nc(2);
+ BOOST_TEST(boost::queue_op_status::success == q.try_pull(nc));
+ BOOST_TEST_EQ(nc, nc1);
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(! q.closed());
+ }
+ {
+ // 1-element queue nonblocking_pull_front succeed
+ boost::deque_adaptor<boost::sync_deque<int> > sq;
+ boost::deque_front<int> q(sq);
+ sq.push_back(1);
+ int i;
+ BOOST_TEST(boost::queue_op_status::success == q.nonblocking_pull(i));
+ BOOST_TEST_EQ(i, 1);
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(! q.closed());
+ }
+ {
+ // 1-element queue nonblocking_pull_front succeed
+ boost::deque_adaptor<boost::sync_deque<non_copyable> > sq;
+ boost::deque_front<non_copyable> q(sq);
+ non_copyable nc1(1);
+ sq.push_back(boost::move(nc1));
+ non_copyable nc(2);
+ BOOST_TEST(boost::queue_op_status::success == q.nonblocking_pull(nc));
+ BOOST_TEST_EQ(nc, nc1);
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(! q.closed());
+ }
+ {
+ // 1-element queue wait_pull_front succeed
+ boost::deque_adaptor<boost::sync_deque<non_copyable> > sq;
+ boost::deque_front<non_copyable> q(sq);
+ non_copyable nc1(1);
+ sq.push_back(boost::move(nc1));
+ non_copyable nc(2);
+ BOOST_TEST(boost::queue_op_status::success == q.wait_pull(nc));
+ BOOST_TEST_EQ(nc, nc1);
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(! q.closed());
+ }
+ {
+ // 1-element queue wait_pull_front succeed
+ boost::deque_adaptor<boost::sync_deque<int> > sq;
+ boost::deque_front<int> q(sq);
+ sq.push_back(1);
+ int i;
+ BOOST_TEST(boost::queue_op_status::success == q.wait_pull(i));
+ BOOST_TEST_EQ(i, 1);
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(! q.closed());
+ }
+ {
+ // 1-element queue wait_pull_front succeed
+ boost::deque_adaptor<boost::sync_deque<non_copyable> > sq;
+ boost::deque_front<non_copyable> q(sq);
+ non_copyable nc1(1);
+ sq.push_back(boost::move(nc1));
+ non_copyable nc(2);
+ BOOST_TEST(boost::queue_op_status::success == q.wait_pull(nc));
+ BOOST_TEST_EQ(nc, nc1);
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(! q.closed());
+ }
+
+ {
+ // closed invariants
+ boost::deque_adaptor<boost::sync_deque<int> > sq;
+ boost::deque_back<int> q(sq);
+ q.close();
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(q.closed());
+ }
+ {
+ // closed invariants
+ boost::deque_adaptor<boost::sync_deque<int> > sq;
+ boost::deque_front<int> q(sq);
+ q.close();
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(q.closed());
+ }
+ {
+ // closed queue push fails
+ boost::deque_adaptor<boost::sync_deque<int> > sq;
+ boost::deque_back<int> q(sq);
+ q.close();
+ try {
+ q.push(1);
+ BOOST_TEST(false);
+ } catch (...) {
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(q.closed());
+ }
+ }
+ {
+ // 1-element closed queue pull succeed
+ boost::deque_adaptor<boost::sync_deque<int> > sq;
+ boost::deque_front<int> q(sq);
+ sq.push_back(1);
+ q.close();
+ int i;
+ q.pull(i);
+ BOOST_TEST_EQ(i, 1);
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(q.closed());
+ }
+ {
+ // 1-element closed queue wait_pull_front succeed
+ boost::deque_adaptor<boost::sync_deque<int> > sq;
+ boost::deque_front<int> q(sq);
+ sq.push_back(1);
+ q.close();
+ int i;
+ BOOST_TEST(boost::queue_op_status::success == q.wait_pull(i));
+ BOOST_TEST_EQ(i, 1);
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(q.closed());
+ }
+ {
+ // closed empty queue wait_pull_front fails
+ boost::deque_adaptor<boost::sync_deque<int> > sq;
+ boost::deque_front<int> q(sq);
+ q.close();
+ BOOST_TEST(q.empty());
+ BOOST_TEST(q.closed());
+ int i;
+ BOOST_TEST(boost::queue_op_status::closed == q.wait_pull(i));
+ BOOST_TEST(q.empty());
+ BOOST_TEST(q.closed());
+ }
+ return boost::report_errors();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/queue_views/single_thread_pass.cpp b/libs/thread/test/sync/mutual_exclusion/queue_views/single_thread_pass.cpp
index 141c23a4f..41cf1cf3a 100644
--- a/libs/thread/test/sync/mutual_exclusion/queue_views/single_thread_pass.cpp
+++ b/libs/thread/test/sync/mutual_exclusion/queue_views/single_thread_pass.cpp
@@ -12,7 +12,7 @@
#define BOOST_THREAD_VERSION 4
//#define BOOST_THREAD_QUEUE_DEPRECATE_OLD
-#include <boost/thread/sync_queue.hpp>
+#include <boost/thread/concurrent_queues/sync_queue.hpp>
#include <boost/thread/concurrent_queues/queue_adaptor.hpp>
#include <boost/thread/concurrent_queues/queue_views.hpp>
@@ -117,7 +117,7 @@ int main()
//boost::sync_queue<non_copyable> q;
//boost::queue_back<non_copyable> q(sq);
non_copyable nc(1);
- q.push_back(boost::move(nc));
+ q.push(boost::move(nc));
BOOST_TEST(! q.empty());
BOOST_TEST(! q.full());
BOOST_TEST_EQ(q.size(), 1u);
@@ -206,7 +206,7 @@ int main()
#if 0
{
- // empty queue nonblocking_push_back rvalue/non-copyable succeeds
+ // empty queue nonblocking_push rvalue/non-copyable succeeds
boost::queue_adaptor<boost::sync_queue<non_copyable> > sq;
boost::queue_back<non_copyable> q(sq);
BOOST_TEST(boost::queue_op_status::success == q.nonblocking_push(non_copyable(1)));
@@ -217,7 +217,7 @@ int main()
}
#endif
{
- // empty queue nonblocking_push_back rvalue/non-copyable succeeds
+ // empty queue nonblocking_push rvalue/non-copyable succeeds
boost::queue_adaptor<boost::sync_queue<non_copyable> > sq;
boost::queue_back<non_copyable> q(sq);
non_copyable nc(1);
@@ -228,10 +228,10 @@ int main()
BOOST_TEST(! q.closed());
}
{
- // 1-element queue pull_front succeed
+ // 1-element queue pull succeed
boost::queue_adaptor<boost::sync_queue<int> > sq;
boost::queue_front<int> q(sq);
- sq.push_back(1);
+ sq.push(1);
int i;
q.pull(i);
BOOST_TEST_EQ(i, 1);
@@ -241,11 +241,11 @@ int main()
BOOST_TEST(! q.closed());
}
{
- // 1-element queue pull_front succeed
+ // 1-element queue pull succeed
boost::queue_adaptor<boost::sync_queue<non_copyable> > sq;
boost::queue_front<non_copyable> q(sq);
non_copyable nc1(1);
- sq.push_back(boost::move(nc1));
+ sq.push(boost::move(nc1));
non_copyable nc2(2);
q.pull(nc2);
BOOST_TEST_EQ(nc1, nc2);
@@ -255,10 +255,10 @@ int main()
BOOST_TEST(! q.closed());
}
{
- // 1-element queue pull_front succeed
+ // 1-element queue pull succeed
boost::queue_adaptor<boost::sync_queue<int> > sq;
boost::queue_front<int> q(sq);
- sq.push_back(1);
+ sq.push(1);
int i = q.pull();
BOOST_TEST_EQ(i, 1);
BOOST_TEST(q.empty());
@@ -267,11 +267,11 @@ int main()
BOOST_TEST(! q.closed());
}
{
- // 1-element queue pull_front succeed
+ // 1-element queue pull succeed
boost::queue_adaptor<boost::sync_queue<non_copyable> > sq;
boost::queue_front<non_copyable> q(sq);
non_copyable nc1(1);
- sq.push_back(boost::move(nc1));
+ sq.push(boost::move(nc1));
non_copyable nc = q.pull();
BOOST_TEST_EQ(nc, nc1);
BOOST_TEST(q.empty());
@@ -280,10 +280,10 @@ int main()
BOOST_TEST(! q.closed());
}
{
- // 1-element queue try_pull_front succeed
+ // 1-element queue try_pull succeed
boost::queue_adaptor<boost::sync_queue<int> > sq;
boost::queue_front<int> q(sq);
- sq.push_back(1);
+ sq.push(1);
int i;
BOOST_TEST(boost::queue_op_status::success == q.try_pull(i));
BOOST_TEST_EQ(i, 1);
@@ -293,11 +293,11 @@ int main()
BOOST_TEST(! q.closed());
}
{
- // 1-element queue try_pull_front succeed
+ // 1-element queue try_pull succeed
boost::queue_adaptor<boost::sync_queue<non_copyable> > sq;
boost::queue_front<non_copyable> q(sq);
non_copyable nc1(1);
- sq.push_back(boost::move(nc1));
+ sq.push(boost::move(nc1));
non_copyable nc(2);
BOOST_TEST(boost::queue_op_status::success == q.try_pull(nc));
BOOST_TEST_EQ(nc, nc1);
@@ -307,10 +307,10 @@ int main()
BOOST_TEST(! q.closed());
}
{
- // 1-element queue nonblocking_pull_front succeed
+ // 1-element queue nonblocking_pull succeed
boost::queue_adaptor<boost::sync_queue<int> > sq;
boost::queue_front<int> q(sq);
- sq.push_back(1);
+ sq.push(1);
int i;
BOOST_TEST(boost::queue_op_status::success == q.nonblocking_pull(i));
BOOST_TEST_EQ(i, 1);
@@ -320,11 +320,11 @@ int main()
BOOST_TEST(! q.closed());
}
{
- // 1-element queue nonblocking_pull_front succeed
+ // 1-element queue nonblocking_pull succeed
boost::queue_adaptor<boost::sync_queue<non_copyable> > sq;
boost::queue_front<non_copyable> q(sq);
non_copyable nc1(1);
- sq.push_back(boost::move(nc1));
+ sq.push(boost::move(nc1));
non_copyable nc(2);
BOOST_TEST(boost::queue_op_status::success == q.nonblocking_pull(nc));
BOOST_TEST_EQ(nc, nc1);
@@ -334,11 +334,11 @@ int main()
BOOST_TEST(! q.closed());
}
{
- // 1-element queue wait_pull_front succeed
+ // 1-element queue wait_pull succeed
boost::queue_adaptor<boost::sync_queue<non_copyable> > sq;
boost::queue_front<non_copyable> q(sq);
non_copyable nc1(1);
- sq.push_back(boost::move(nc1));
+ sq.push(boost::move(nc1));
non_copyable nc(2);
BOOST_TEST(boost::queue_op_status::success == q.wait_pull(nc));
BOOST_TEST_EQ(nc, nc1);
@@ -348,10 +348,10 @@ int main()
BOOST_TEST(! q.closed());
}
{
- // 1-element queue wait_pull_front succeed
+ // 1-element queue wait_pull succeed
boost::queue_adaptor<boost::sync_queue<int> > sq;
boost::queue_front<int> q(sq);
- sq.push_back(1);
+ sq.push(1);
int i;
BOOST_TEST(boost::queue_op_status::success == q.wait_pull(i));
BOOST_TEST_EQ(i, 1);
@@ -361,11 +361,11 @@ int main()
BOOST_TEST(! q.closed());
}
{
- // 1-element queue wait_pull_front succeed
+ // 1-element queue wait_pull succeed
boost::queue_adaptor<boost::sync_queue<non_copyable> > sq;
boost::queue_front<non_copyable> q(sq);
non_copyable nc1(1);
- sq.push_back(boost::move(nc1));
+ sq.push(boost::move(nc1));
non_copyable nc(2);
BOOST_TEST(boost::queue_op_status::success == q.wait_pull(nc));
BOOST_TEST_EQ(nc, nc1);
@@ -414,7 +414,7 @@ int main()
// 1-element closed queue pull succeed
boost::queue_adaptor<boost::sync_queue<int> > sq;
boost::queue_front<int> q(sq);
- sq.push_back(1);
+ sq.push(1);
q.close();
int i;
q.pull(i);
@@ -425,10 +425,10 @@ int main()
BOOST_TEST(q.closed());
}
{
- // 1-element closed queue wait_pull_front succeed
+ // 1-element closed queue wait_pull succeed
boost::queue_adaptor<boost::sync_queue<int> > sq;
boost::queue_front<int> q(sq);
- sq.push_back(1);
+ sq.push(1);
q.close();
int i;
BOOST_TEST(boost::queue_op_status::success == q.wait_pull(i));
@@ -439,7 +439,7 @@ int main()
BOOST_TEST(q.closed());
}
{
- // closed empty queue wait_pull_front fails
+ // closed empty queue wait_pull fails
boost::queue_adaptor<boost::sync_queue<int> > sq;
boost::queue_front<int> q(sq);
q.close();
diff --git a/libs/thread/test/sync/mutual_exclusion/sync_deque/multi_thread_pass.cpp b/libs/thread/test/sync/mutual_exclusion/sync_deque/multi_thread_pass.cpp
new file mode 100644
index 000000000..703c54f40
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/sync_deque/multi_thread_pass.cpp
@@ -0,0 +1,256 @@
+// Copyright (C) 2013 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/concurrent_queues/sync_deque.hpp>
+
+// class sync_deque<T>
+
+// push || pull;
+
+#include <boost/config.hpp>
+#if ! defined BOOST_NO_CXX11_DECLTYPE
+#define BOOST_RESULT_OF_USE_DECLTYPE
+#endif
+
+#define BOOST_THREAD_VERSION 4
+
+#include <boost/thread/concurrent_queues/sync_deque.hpp>
+#include <boost/thread/future.hpp>
+#include <boost/thread/barrier.hpp>
+
+#include <boost/detail/lightweight_test.hpp>
+
+template <typename ValueType>
+struct call_push_back
+{
+ boost::sync_deque<ValueType> *q_;
+ boost::barrier *go_;
+
+ call_push_back(boost::sync_deque<ValueType> *q, boost::barrier *go) :
+ q_(q), go_(go)
+ {
+ }
+ typedef void result_type;
+ void operator()()
+ {
+ go_->count_down_and_wait();
+ q_->push_back(42);
+ }
+};
+
+template <typename ValueType>
+struct call_pull_front
+{
+ boost::sync_deque<ValueType> *q_;
+ boost::barrier *go_;
+
+ call_pull_front(boost::sync_deque<ValueType> *q, boost::barrier *go) :
+ q_(q), go_(go)
+ {
+ }
+ typedef ValueType result_type;
+ ValueType operator()()
+ {
+ go_->count_down_and_wait();
+ return q_->pull_front();
+ }
+};
+
+template <typename ValueType>
+struct call_wait_pull_front
+{
+ boost::sync_deque<ValueType> *q_;
+ boost::barrier *go_;
+
+ call_wait_pull_front(boost::sync_deque<ValueType> *q, boost::barrier *go) :
+ q_(q), go_(go)
+ {
+ }
+ typedef boost::queue_op_status result_type;
+ boost::queue_op_status operator()(ValueType& v)
+ {
+ go_->wait();
+ return q_->wait_pull_front(v);
+ }
+};
+
+void test_concurrent_push_back_and_pull_front_on_empty_queue()
+{
+ boost::sync_deque<int> q;
+
+ boost::barrier go(2);
+
+ boost::future<void> push_done;
+ boost::future<int> pull_done;
+
+ try
+ {
+ push_done=boost::async(boost::launch::async,
+ call_push_back<int>(&q,&go));
+ pull_done=boost::async(boost::launch::async,
+ call_pull_front<int>(&q,&go));
+
+ push_done.get();
+ BOOST_TEST_EQ(pull_done.get(), 42);
+ BOOST_TEST(q.empty());
+ }
+ catch (...)
+ {
+ BOOST_TEST(false);
+ }
+}
+
+#if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
+void test_concurrent_push_back_and_wait_pull_front_on_empty_queue()
+{
+ boost::sync_deque<int> q;
+ const unsigned int n = 3;
+ boost::barrier go(n);
+
+ boost::future<boost::queue_op_status> pull_done[n];
+ int results[n];
+
+ try
+ {
+ for (unsigned int i =0; i< n; ++i)
+ pull_done[i]=boost::async(boost::launch::async,
+ call_wait_pull_front<int>(&q,&go),
+ boost::ref(results[i]));
+
+ for (unsigned int i =0; i< n; ++i)
+ q.push_back(42);
+
+ for (unsigned int i = 0; i < n; ++i) {
+ BOOST_TEST(pull_done[i].get() == boost::queue_op_status::success);
+ BOOST_TEST_EQ(results[i], 42);
+ }
+ BOOST_TEST(q.empty());
+ }
+ catch (...)
+ {
+ BOOST_TEST(false);
+ }
+}
+
+void test_concurrent_wait_pull_front_and_close_on_empty_queue()
+{
+ boost::sync_deque<int> q;
+ const unsigned int n = 3;
+ boost::barrier go(n);
+
+ boost::future<boost::queue_op_status> pull_done[n];
+ int results[n];
+
+ try
+ {
+ for (unsigned int i =0; i< n; ++i)
+ pull_done[i]=boost::async(boost::launch::async,
+ call_wait_pull_front<int>(&q,&go),
+ boost::ref(results[i]));
+
+ q.close();
+
+ for (unsigned int i = 0; i < n; ++i) {
+ BOOST_TEST(pull_done[i].get() == boost::queue_op_status::closed);
+ }
+ BOOST_TEST(q.empty());
+ }
+ catch (...)
+ {
+ BOOST_TEST(false);
+ }
+}
+#endif
+
+void test_concurrent_push_back_on_empty_queue()
+{
+ boost::sync_deque<int> q;
+ const unsigned int n = 3;
+ boost::barrier go(n);
+ boost::future<void> push_done[n];
+
+ try
+ {
+ for (unsigned int i =0; i< n; ++i)
+ push_done[i]=boost::async(boost::launch::async,
+ call_push_back<int>(&q,&go));
+
+ }
+ catch (...)
+ {
+ BOOST_TEST(false);
+ }
+ try
+ {
+ for (unsigned int i = 0; i < n; ++i)
+ push_done[i].get();
+
+ }
+ catch (...)
+ {
+ BOOST_TEST(false);
+ }
+ try
+ {
+ BOOST_TEST(!q.empty());
+ for (unsigned int i =0; i< n; ++i)
+ BOOST_TEST_EQ(q.pull_front(), 42);
+ BOOST_TEST(q.empty());
+
+ }
+ catch (...)
+ {
+ BOOST_TEST(false);
+ }
+}
+
+void test_concurrent_pull_front_on_queue()
+{
+ boost::sync_deque<int> q;
+ const unsigned int n = 3;
+ boost::barrier go(n);
+
+ boost::future<int> pull_done[n];
+
+ try
+ {
+ for (unsigned int i =0; i< n; ++i)
+ q.push_back(42);
+
+ for (unsigned int i =0; i< n; ++i)
+ pull_done[i]=boost::async(boost::launch::async,
+#if ! defined BOOST_NO_CXX11_LAMBDAS
+ [&q,&go]() -> int
+ {
+ go.wait();
+ return q.pull_front();
+ }
+#else
+ call_pull_front<int>(&q,&go)
+#endif
+ );
+
+ for (unsigned int i = 0; i < n; ++i)
+ BOOST_TEST_EQ(pull_done[i].get(), 42);
+ BOOST_TEST(q.empty());
+ }
+ catch (...)
+ {
+ BOOST_TEST(false);
+ }
+}
+
+int main()
+{
+ test_concurrent_push_back_and_pull_front_on_empty_queue();
+#if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
+ test_concurrent_push_back_and_wait_pull_front_on_empty_queue();
+ test_concurrent_wait_pull_front_and_close_on_empty_queue();
+#endif
+ test_concurrent_push_back_on_empty_queue();
+ test_concurrent_pull_front_on_queue();
+ return boost::report_errors();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/sync_deque/single_thread_pass.cpp b/libs/thread/test/sync/mutual_exclusion/sync_deque/single_thread_pass.cpp
new file mode 100644
index 000000000..5170bcf61
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/sync_deque/single_thread_pass.cpp
@@ -0,0 +1,403 @@
+// Copyright (C) 2013,2015 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// <boost/thread/concurrent_queues/sync_deque.hpp>
+
+// class sync_deque<T>
+
+// sync_deque();
+
+#define BOOST_THREAD_VERSION 4
+
+#include <boost/thread/concurrent_queues/sync_deque.hpp>
+
+#include <boost/detail/lightweight_test.hpp>
+
+class non_copyable
+{
+ BOOST_THREAD_MOVABLE_ONLY(non_copyable)
+ int val;
+public:
+ non_copyable(int v) : val(v){}
+ non_copyable(BOOST_RV_REF(non_copyable) x): val(x.val) {}
+ non_copyable& operator=(BOOST_RV_REF(non_copyable) x) { val=x.val; return *this; }
+ bool operator==(non_copyable const& x) const {return val==x.val;}
+ template <typename OSTREAM>
+ friend OSTREAM& operator <<(OSTREAM& os, non_copyable const&x )
+ {
+ os << x.val;
+ return os;
+ }
+
+};
+
+
+
+int main()
+{
+
+ {
+ // default queue invariants
+ boost::sync_deque<int> q;
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(! q.closed());
+ }
+ {
+ // empty queue try_pull fails
+ boost::sync_deque<int> q;
+ int i;
+ BOOST_TEST( boost::queue_op_status::empty == q.try_pull_front(i));
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(! q.closed());
+ }
+ {
+ // empty queue push rvalue/copyable succeeds
+ boost::sync_deque<int> q;
+ q.push_back(1);
+ BOOST_TEST(! q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 1u);
+ BOOST_TEST(! q.closed());
+ }
+ {
+ // empty queue push lvalue/copyable succeeds
+ boost::sync_deque<int> q;
+ int i;
+ q.push_back(i);
+ BOOST_TEST(! q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 1u);
+ BOOST_TEST(! q.closed());
+ }
+
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
+ {
+ // empty queue push rvalue/non_copyable succeeds
+ boost::sync_deque<non_copyable> q;
+ q.push_back(non_copyable(1));
+ BOOST_TEST(! q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 1u);
+ BOOST_TEST(! q.closed());
+ }
+#endif
+ {
+ // empty queue push rvalue/non_copyable succeeds
+ boost::sync_deque<non_copyable> q;
+ non_copyable nc(1);
+ q.push_back(boost::move(nc));
+ BOOST_TEST(! q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 1u);
+ BOOST_TEST(! q.closed());
+ }
+
+ {
+ // empty queue push rvalue succeeds
+ boost::sync_deque<int> q;
+ q.push_back(1);
+ q.push_back(2);
+ BOOST_TEST(! q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 2u);
+ BOOST_TEST(! q.closed());
+ }
+ {
+ // empty queue push lvalue succeeds
+ boost::sync_deque<int> q;
+ int i;
+ q.push_back(i);
+ BOOST_TEST(! q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 1u);
+ BOOST_TEST(! q.closed());
+ }
+ {
+ // empty queue try_push rvalue/copyable succeeds
+ boost::sync_deque<int> q;
+ BOOST_TEST(boost::queue_op_status::success == q.try_push_back(1));
+ BOOST_TEST(! q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 1u);
+ BOOST_TEST(! q.closed());
+ }
+ {
+ // empty queue try_push rvalue/copyable succeeds
+ boost::sync_deque<int> q;
+ BOOST_TEST(boost::queue_op_status::success == q.try_push_back(1));
+ BOOST_TEST(! q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 1u);
+ BOOST_TEST(! q.closed());
+ }
+
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
+ {
+ // empty queue try_push rvalue/non-copyable succeeds
+ boost::sync_deque<non_copyable> q;
+ BOOST_TEST(boost::queue_op_status::success ==q.try_push_back(non_copyable(1)));
+ BOOST_TEST(! q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 1u);
+ BOOST_TEST(! q.closed());
+ }
+#endif
+ {
+ // empty queue try_push rvalue/non-copyable succeeds
+ boost::sync_deque<non_copyable> q;
+ non_copyable nc(1);
+ BOOST_TEST(boost::queue_op_status::success == q.try_push_back(boost::move(nc)));
+ BOOST_TEST(! q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 1u);
+ BOOST_TEST(! q.closed());
+ }
+
+ {
+ // empty queue try_push lvalue succeeds
+ boost::sync_deque<int> q;
+ int i=1;
+ BOOST_TEST(boost::queue_op_status::success == q.try_push_back(i));
+ BOOST_TEST(! q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 1u);
+ BOOST_TEST(! q.closed());
+ }
+ {
+ // empty queue try_push rvalue succeeds
+ boost::sync_deque<int> q;
+ BOOST_TEST(boost::queue_op_status::success == q.nonblocking_push_back(1));
+ BOOST_TEST(! q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 1u);
+ BOOST_TEST(! q.closed());
+ }
+
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
+ {
+ // empty queue nonblocking_push_back rvalue/non-copyable succeeds
+ boost::sync_deque<non_copyable> q;
+ BOOST_TEST(boost::queue_op_status::success == q.nonblocking_push_back(non_copyable(1)));
+ BOOST_TEST(! q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 1u);
+ BOOST_TEST(! q.closed());
+ }
+#endif
+ {
+ // empty queue nonblocking_push_back rvalue/non-copyable succeeds
+ boost::sync_deque<non_copyable> q;
+ non_copyable nc(1);
+ BOOST_TEST(boost::queue_op_status::success == q.nonblocking_push_back(boost::move(nc)));
+ BOOST_TEST(! q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 1u);
+ BOOST_TEST(! q.closed());
+ }
+ {
+ // 1-element queue pull_front succeed
+ boost::sync_deque<int> q;
+ q.push_back(1);
+ int i;
+ q.pull_front(i);
+ BOOST_TEST_EQ(i, 1);
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(! q.closed());
+ }
+ {
+ // 1-element queue pull_front succeed
+ boost::sync_deque<non_copyable> q;
+ non_copyable nc1(1);
+ q.push_back(boost::move(nc1));
+ non_copyable nc2(2);
+ q.pull_front(nc2);
+ BOOST_TEST_EQ(nc1, nc2);
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(! q.closed());
+ }
+ {
+ // 1-element queue pull_front succeed
+ boost::sync_deque<int> q;
+ q.push_back(1);
+ int i = q.pull_front();
+ BOOST_TEST_EQ(i, 1);
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(! q.closed());
+ }
+ {
+ // 1-element queue pull_front succeed
+ boost::sync_deque<non_copyable> q;
+ non_copyable nc1(1);
+ q.push_back(boost::move(nc1));
+ non_copyable nc = q.pull_front();
+ BOOST_TEST_EQ(nc, nc1);
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(! q.closed());
+ }
+ {
+ // 1-element queue try_pull_front succeed
+ boost::sync_deque<int> q;
+ q.push_back(1);
+ int i;
+ BOOST_TEST(boost::queue_op_status::success == q.try_pull_front(i));
+ BOOST_TEST_EQ(i, 1);
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(! q.closed());
+ }
+ {
+ // 1-element queue try_pull_front succeed
+ boost::sync_deque<non_copyable> q;
+ non_copyable nc1(1);
+ q.push_back(boost::move(nc1));
+ non_copyable nc(2);
+ BOOST_TEST(boost::queue_op_status::success == q.try_pull_front(nc));
+ BOOST_TEST_EQ(nc, nc1);
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(! q.closed());
+ }
+ {
+ // 1-element queue nonblocking_pull_front succeed
+ boost::sync_deque<int> q;
+ q.push_back(1);
+ int i;
+ BOOST_TEST(boost::queue_op_status::success == q.nonblocking_pull_front(i));
+ BOOST_TEST_EQ(i, 1);
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(! q.closed());
+ }
+ {
+ // 1-element queue nonblocking_pull_front succeed
+ boost::sync_deque<non_copyable> q;
+ non_copyable nc1(1);
+ q.push_back(boost::move(nc1));
+ non_copyable nc(2);
+ BOOST_TEST(boost::queue_op_status::success == q.nonblocking_pull_front(nc));
+ BOOST_TEST_EQ(nc, nc1);
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(! q.closed());
+ }
+ {
+ // 1-element queue wait_pull_front succeed
+ boost::sync_deque<non_copyable> q;
+ non_copyable nc1(1);
+ q.push_back(boost::move(nc1));
+ non_copyable nc(2);
+ BOOST_TEST(boost::queue_op_status::success == q.wait_pull_front(nc));
+ BOOST_TEST_EQ(nc, nc1);
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(! q.closed());
+ }
+ {
+ // 1-element queue wait_pull_front succeed
+ boost::sync_deque<int> q;
+ q.push_back(1);
+ int i;
+ BOOST_TEST(boost::queue_op_status::success == q.wait_pull_front(i));
+ BOOST_TEST_EQ(i, 1);
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(! q.closed());
+ }
+ {
+ // 1-element queue wait_pull_front succeed
+ boost::sync_deque<non_copyable> q;
+ non_copyable nc1(1);
+ q.push_back(boost::move(nc1));
+ non_copyable nc(2);
+ BOOST_TEST(boost::queue_op_status::success == q.wait_pull_front(nc));
+ BOOST_TEST_EQ(nc, nc1);
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(! q.closed());
+ }
+
+ {
+ // closed invariants
+ boost::sync_deque<int> q;
+ q.close();
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(q.closed());
+ }
+ {
+ // closed queue push fails
+ boost::sync_deque<int> q;
+ q.close();
+ try {
+ q.push_back(1);
+ BOOST_TEST(false);
+ } catch (...) {
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(q.closed());
+ }
+ }
+ {
+ // 1-element closed queue pull succeed
+ boost::sync_deque<int> q;
+ q.push_back(1);
+ q.close();
+ int i;
+ q.pull_front(i);
+ BOOST_TEST_EQ(i, 1);
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(q.closed());
+ }
+ {
+ // 1-element closed queue wait_pull_front succeed
+ boost::sync_deque<int> q;
+ q.push_back(1);
+ q.close();
+ int i;
+ BOOST_TEST(boost::queue_op_status::success == q.wait_pull_front(i));
+ BOOST_TEST_EQ(i, 1);
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(q.closed());
+ }
+ {
+ // closed empty queue wait_pull_front fails
+ boost::sync_deque<int> q;
+ q.close();
+ BOOST_TEST(q.empty());
+ BOOST_TEST(q.closed());
+ int i;
+ BOOST_TEST(boost::queue_op_status::closed == q.wait_pull_front(i));
+ BOOST_TEST(q.empty());
+ BOOST_TEST(q.closed());
+ }
+
+ return boost::report_errors();
+}
+
diff --git a/libs/thread/test/sync/mutual_exclusion/sync_pq/pq_multi_thread_pass.cpp b/libs/thread/test/sync/mutual_exclusion/sync_pq/pq_multi_thread_pass.cpp
new file mode 100644
index 000000000..d8e82c2e6
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/sync_pq/pq_multi_thread_pass.cpp
@@ -0,0 +1,215 @@
+// Copyright (C) 2014 Ian Forbed
+// Copyright (C) 2014 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+
+#include <boost/config.hpp>
+#if ! defined BOOST_NO_CXX11_DECLTYPE
+#define BOOST_RESULT_OF_USE_DECLTYPE
+#endif
+
+#define BOOST_THREAD_VERSION 4
+#define BOOST_THREAD_PROVIDES_EXECUTORS
+
+#include <exception>
+
+#include <boost/thread/thread.hpp>
+#include <boost/thread/barrier.hpp>
+#include <boost/thread/concurrent_queues/sync_priority_queue.hpp>
+
+#include <boost/core/lightweight_test.hpp>
+
+typedef boost::concurrent::sync_priority_queue<int> sync_pq;
+
+int call_pull(sync_pq* q, boost::barrier* go)
+{
+ go->wait();
+ return q->pull();
+
+}
+
+void call_push(sync_pq* q, boost::barrier* go, int val)
+{
+ go->wait();
+ q->push(val);
+}
+
+void test_pull(const int n)
+{
+ sync_pq pq;
+ BOOST_TEST(pq.empty());
+ for(int i = 0; i < n; i++)
+ {
+ pq.push(i);
+ }
+ BOOST_TEST(!pq.empty());
+ BOOST_TEST_EQ(pq.size(), std::size_t(n));
+ pq.close();
+ BOOST_TEST(pq.closed());
+ boost::barrier b(n);
+ boost::thread_group tg;
+ for(int i = 0; i < n; i++)
+ {
+ tg.create_thread(boost::bind(call_pull, &pq, &b));
+ }
+ tg.join_all();
+ BOOST_TEST(pq.empty());
+}
+
+void test_push(const int n)
+{
+ sync_pq pq;
+ BOOST_TEST(pq.empty());
+
+ boost::barrier b(n);
+ boost::thread_group tg;
+ for(int i = 0; i < n; i++)
+ {
+ tg.create_thread(boost::bind(call_push, &pq, &b, i));
+ }
+ tg.join_all();
+ BOOST_TEST(!pq.empty());
+ BOOST_TEST_EQ(pq.size(), std::size_t(n));
+}
+
+void test_both(const int n)
+{
+ sync_pq pq;
+ BOOST_TEST(pq.empty());
+
+ boost::barrier b(2*n);
+ boost::thread_group tg;
+ for(int i = 0; i < n; i++)
+ {
+ tg.create_thread(boost::bind(call_pull, &pq, &b));
+ tg.create_thread(boost::bind(call_push, &pq, &b, i));
+ }
+ tg.join_all();
+ BOOST_TEST(pq.empty());
+ BOOST_TEST_EQ(pq.size(), std::size_t(0));
+}
+
+void push_range(sync_pq* q, const int begin, const int end)
+{
+ for(int i = begin; i < end; i++)
+ q->push(i);
+}
+
+void atomic_pull(sync_pq* q, boost::atomic<int>* sum)
+{
+ while(1)
+ {
+ try{
+ const int val = q->pull();
+ sum->fetch_add(val);
+ }
+ catch(std::exception& e ){
+ break;
+ }
+ }
+}
+
+/**
+ * This test computes the sum of the first N integers upto $limit using
+ * $n threads for the push operation and $n threads for the pull and count
+ * operation. The push operation push a range of numbers on the queue while
+ * the pull operation pull from the queue and increments an atomic int.
+ * At the end of execution the value of atomic<int> $sum should be the same
+ * as n*(n+1)/2 as this is the closed form solution to this problem.
+ */
+void compute_sum(const int n)
+{
+ const int limit = 1000;
+ sync_pq pq;
+ BOOST_TEST(pq.empty());
+ boost::atomic<int> sum(0);
+ boost::thread_group tg1;
+ boost::thread_group tg2;
+ for(int i = 0; i < n; i++)
+ {
+ tg1.create_thread(boost::bind(push_range, &pq, i*(limit/n)+1, (i+1)*(limit/n)+1));
+ tg2.create_thread(boost::bind(atomic_pull, &pq, &sum));
+ }
+ tg1.join_all();
+ pq.close(); //Wait until all enqueuing is done before closing.
+ BOOST_TEST(pq.closed());
+ tg2.join_all();
+ BOOST_TEST(pq.empty());
+ BOOST_TEST_EQ(sum.load(), limit*(limit+1)/2);
+}
+
+void move_between_queues(sync_pq* q1, sync_pq* q2)
+{
+ while(1){
+ try{
+ const int val = q1->pull();
+ q2->push(val);
+ }
+ catch(std::exception& e){
+ break;
+ }
+ }
+}
+
+/**
+ * This test computes the sum of the first N integers upto $limit by moving
+ * numbers between 2 sync_priority_queues. A range of numbers are pushed onto
+ * one queue by $n threads while $n threads pull from this queue and push onto
+ * another sync_pq. At the end the main thread ensures the the values in the
+ * second queue are in proper order and then sums all the values from this
+ * queue. The sum should match n*(n+1)/2, the closed form solution to this
+ * problem.
+ */
+void sum_with_moving(const int n)
+{
+ const int limit = 1000;
+ sync_pq pq1;
+ sync_pq pq2;
+ BOOST_TEST(pq1.empty());
+ BOOST_TEST(pq2.empty());
+ boost::thread_group tg1;
+ boost::thread_group tg2;
+ for(int i = 0; i < n; i++)
+ {
+ tg1.create_thread(boost::bind(push_range, &pq1, i*(limit/n)+1, (i+1)*(limit/n)+1));
+ tg2.create_thread(boost::bind(move_between_queues, &pq1, &pq2));
+ }
+ tg1.join_all();
+ pq1.close(); //Wait until all enqueuing is done before closing.
+ BOOST_TEST(pq1.closed());
+ tg2.join_all();
+ BOOST_TEST(pq1.empty());
+ BOOST_TEST(!pq2.empty());
+ int sum = 0;
+ for(int i = 1000; i > 0; i--){
+ const int val = pq2.pull();
+ BOOST_TEST_EQ(i,val);
+ sum += val;
+ }
+ BOOST_TEST(pq2.empty());
+ BOOST_TEST_EQ(sum, limit*(limit+1)/2);
+}
+
+int main()
+{
+ for(int i = 1; i <= 64; i *= 2)
+ {
+ test_pull(i);
+ test_push(i);
+ test_both(i);
+ }
+ //These numbers must divide 1000
+ compute_sum(1);
+ compute_sum(4);
+ compute_sum(10);
+ compute_sum(25);
+ compute_sum(50);
+ sum_with_moving(1);
+ sum_with_moving(4);
+ sum_with_moving(10);
+ sum_with_moving(25);
+ sum_with_moving(50);
+ return boost::report_errors();
+}
diff --git a/libs/thread/test/sync/mutual_exclusion/sync_pq/pq_single_thread_pass.cpp b/libs/thread/test/sync/mutual_exclusion/sync_pq/pq_single_thread_pass.cpp
new file mode 100644
index 000000000..cc1ae90c6
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/sync_pq/pq_single_thread_pass.cpp
@@ -0,0 +1,425 @@
+// Copyright (C) 2014 Ian Forbed
+// Copyright (C) 2014,2015 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+
+#include <boost/config.hpp>
+#if ! defined BOOST_NO_CXX11_DECLTYPE
+#define BOOST_RESULT_OF_USE_DECLTYPE
+#endif
+
+#define BOOST_THREAD_VERSION 4
+#define BOOST_THREAD_PROVIDES_EXECUTORS
+
+#include <iostream>
+
+#include <boost/thread.hpp>
+#include <boost/chrono.hpp>
+#include <boost/thread/concurrent_queues/sync_priority_queue.hpp>
+
+#include <boost/detail/lightweight_test.hpp>
+
+using namespace boost::chrono;
+
+typedef boost::concurrent::sync_priority_queue<int> sync_pq;
+
+class non_copyable
+{
+ BOOST_THREAD_MOVABLE_ONLY(non_copyable)
+ int val;
+public:
+ non_copyable(int v) : val(v){}
+ non_copyable(BOOST_RV_REF(non_copyable) x): val(x.val) {}
+ non_copyable& operator=(BOOST_RV_REF(non_copyable) x) { val=x.val; return *this; }
+ bool operator==(non_copyable const& x) const {return val==x.val;}
+ template <typename OSTREAM>
+ friend OSTREAM& operator <<(OSTREAM& os, non_copyable const&x )
+ {
+ os << x.val;
+ return os;
+ }
+ bool operator <(const non_copyable& other) const
+ {
+ return val < other.val;
+ }
+};
+
+
+void test_pull_for()
+{
+ sync_pq pq;
+ steady_clock::time_point start = steady_clock::now();
+ int val;
+ boost::queue_op_status st = pq.pull_for(milliseconds(500), val);
+ steady_clock::duration diff = steady_clock::now() - start;
+ BOOST_TEST(boost::queue_op_status::timeout == st);
+ BOOST_TEST(diff < milliseconds(550) && diff > milliseconds(500));
+}
+
+void test_pull_until()
+{
+ sync_pq pq;
+ steady_clock::time_point start = steady_clock::now();
+ int val;
+ boost::queue_op_status st = pq.pull_until(start + milliseconds(500), val);
+ steady_clock::duration diff = steady_clock::now() - start;
+ BOOST_TEST(boost::queue_op_status::timeout == st);
+ BOOST_TEST(diff < milliseconds(550) && diff > milliseconds(500));
+}
+
+void test_nonblocking_pull()
+{
+ sync_pq pq;
+ steady_clock::time_point start = steady_clock::now();
+ int val;
+ boost::queue_op_status st = pq.nonblocking_pull(val);
+ steady_clock::duration diff = steady_clock::now() - start;
+ BOOST_TEST(boost::queue_op_status::empty == st);
+ BOOST_TEST(diff < milliseconds(5));
+}
+
+void test_pull_for_when_not_empty()
+{
+ sync_pq pq;
+ pq.push(1);
+ steady_clock::time_point start = steady_clock::now();
+ int val;
+ boost::queue_op_status st = pq.pull_for(milliseconds(500), val);
+ steady_clock::duration diff = steady_clock::now() - start;
+ BOOST_TEST(boost::queue_op_status::success == st);
+ BOOST_TEST(1 == val);
+ BOOST_TEST(diff < milliseconds(5));
+}
+
+void test_pull_until_when_not_empty()
+{
+ sync_pq pq;
+ pq.push(1);
+ steady_clock::time_point start = steady_clock::now();
+ int val;
+ boost::queue_op_status st = pq.pull_until(start + milliseconds(500), val);
+ steady_clock::duration diff = steady_clock::now() - start;
+ BOOST_TEST(boost::queue_op_status::success == st);
+ BOOST_TEST(1 == val);
+ BOOST_TEST(diff < milliseconds(5));
+}
+
+int main()
+{
+ sync_pq pq;
+ BOOST_TEST(pq.empty());
+ BOOST_TEST(!pq.closed());
+ BOOST_TEST_EQ(pq.size(), std::size_t(0));
+
+ for(int i = 1; i <= 5; i++){
+ pq.push(i);
+ BOOST_TEST(!pq.empty());
+ BOOST_TEST_EQ(pq.size(), std::size_t(i));
+ }
+
+ for(int i = 6; i <= 10; i++){
+ boost::queue_op_status succ = pq.try_push(i);
+ BOOST_TEST(succ == boost::queue_op_status::success );
+ BOOST_TEST(!pq.empty());
+ BOOST_TEST_EQ(pq.size(), std::size_t(i));
+ }
+
+ for(int i = 10; i > 5; i--){
+ int val = pq.pull();
+ BOOST_TEST_EQ(val, i);
+ }
+
+// for(int i = 5; i > 0; i--){
+// boost::optional<int> val = pq.try_pull();
+// BOOST_TEST(val);
+// BOOST_TEST_EQ(*val, i);
+// }
+
+// BOOST_TEST(pq.empty());
+ pq.close();
+ BOOST_TEST(pq.closed());
+
+ test_pull_for();
+ test_pull_until();
+ test_nonblocking_pull();
+
+ test_pull_for_when_not_empty();
+ //test_pull_until_when_not_empty();
+
+#if ! defined BOOST_NO_CXX11_RVALUE_REFERENCES
+ {
+ // empty queue try_push rvalue/non-copyable succeeds
+ boost::concurrent::sync_priority_queue<non_copyable> q;
+ 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());
+ }
+ {
+ //fixme
+ // empty queue try_push rvalue/non-copyable succeeds
+ boost::concurrent::sync_priority_queue<non_copyable> q;
+ non_copyable nc(1);
+ BOOST_TEST(boost::queue_op_status::success == q.try_push(boost::move(nc)));
+ BOOST_TEST(! q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 1u);
+ BOOST_TEST(! q.closed());
+ }
+#endif
+
+ {
+ // empty queue try_push lvalue succeeds
+ boost::concurrent::sync_priority_queue<int> q;
+ int i=1;
+ BOOST_TEST(boost::queue_op_status::success == q.try_push(i));
+ BOOST_TEST(! q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 1u);
+ BOOST_TEST(! q.closed());
+ }
+#if 0
+ {
+ // empty queue try_push rvalue succeeds
+ boost::concurrent::sync_priority_queue<int> 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<non_copyable> q;
+ BOOST_TEST(boost::queue_op_status::success == q.nonblocking_push(non_copyable(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<non_copyable> 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
+
+ {
+ // 1-element queue pull succeed
+ boost::concurrent::sync_priority_queue<int> q;
+ q.push(1);
+ int i;
+ i=q.pull();
+ BOOST_TEST_EQ(i, 1);
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(! q.closed());
+ }
+#if ! defined BOOST_NO_CXX11_RVALUE_REFERENCES
+ {
+ // 1-element queue pull succeed
+ boost::concurrent::sync_priority_queue<non_copyable> q;
+ non_copyable nc1(1);
+ q.push(boost::move(nc1));
+ non_copyable nc2(2);
+ nc2=q.pull();
+ BOOST_TEST_EQ(nc1, nc2);
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(! q.closed());
+ }
+#endif
+
+ {
+ // 1-element queue pull succeed
+ boost::concurrent::sync_priority_queue<int> q;
+ q.push(1);
+ int i = q.pull();
+ BOOST_TEST_EQ(i, 1);
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(! q.closed());
+ }
+#if ! defined BOOST_NO_CXX11_RVALUE_REFERENCES
+ {
+ // 1-element queue pull succeed
+ boost::concurrent::sync_priority_queue<non_copyable> q;
+ non_copyable nc1(1);
+ q.push(boost::move(nc1));
+ non_copyable nc = q.pull();
+ BOOST_TEST_EQ(nc, nc1);
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(! q.closed());
+ }
+#endif
+
+ {
+ // 1-element queue try_pull succeed
+ boost::concurrent::sync_priority_queue<int> q;
+ q.push(1);
+ int i;
+ BOOST_TEST(boost::queue_op_status::success == q.try_pull(i));
+ BOOST_TEST_EQ(i, 1);
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(! q.closed());
+ }
+#if ! defined BOOST_NO_CXX11_RVALUE_REFERENCES
+ {
+ // 1-element queue try_pull succeed
+ boost::concurrent::sync_priority_queue<non_copyable> q;
+ non_copyable nc1(1);
+ q.push(boost::move(nc1));
+ non_copyable nc(2);
+ BOOST_TEST(boost::queue_op_status::success == q.try_pull(nc));
+ BOOST_TEST_EQ(nc, nc1);
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(! q.closed());
+ }
+#endif
+ {
+ // 1-element queue nonblocking_pull succeed
+ boost::concurrent::sync_priority_queue<int> q;
+ q.push(1);
+ int i;
+ BOOST_TEST(boost::queue_op_status::success == q.nonblocking_pull(i));
+ BOOST_TEST_EQ(i, 1);
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(! q.closed());
+ }
+#if ! defined BOOST_NO_CXX11_RVALUE_REFERENCES
+ {
+ // 1-element queue nonblocking_pull succeed
+ boost::concurrent::sync_priority_queue<non_copyable> q;
+ non_copyable nc1(1);
+ q.push(boost::move(nc1));
+ non_copyable nc(2);
+ BOOST_TEST(boost::queue_op_status::success == q.nonblocking_pull(nc));
+ BOOST_TEST_EQ(nc, nc1);
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(! q.closed());
+ }
+ {
+ // 1-element queue wait_pull succeed
+ boost::concurrent::sync_priority_queue<non_copyable> q;
+ non_copyable nc1(1);
+ q.push(boost::move(nc1));
+ non_copyable nc(2);
+ BOOST_TEST(boost::queue_op_status::success == q.wait_pull(nc));
+ BOOST_TEST_EQ(nc, nc1);
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(! q.closed());
+ }
+#endif
+ {
+ // 1-element queue wait_pull succeed
+ boost::concurrent::sync_priority_queue<int> q;
+ q.push(1);
+ int i;
+ BOOST_TEST(boost::queue_op_status::success == q.wait_pull(i));
+ BOOST_TEST_EQ(i, 1);
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(! q.closed());
+ }
+#if ! defined BOOST_NO_CXX11_RVALUE_REFERENCES
+ {
+ // 1-element queue wait_pull succeed
+ boost::concurrent::sync_priority_queue<non_copyable> q;
+ non_copyable nc1(1);
+ q.push(boost::move(nc1));
+ non_copyable nc(2);
+ BOOST_TEST(boost::queue_op_status::success == q.wait_pull(nc));
+ BOOST_TEST_EQ(nc, nc1);
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(! q.closed());
+ }
+#endif
+
+ {
+ // closed invariants
+ boost::concurrent::sync_priority_queue<int> q;
+ q.close();
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(q.closed());
+ }
+ {
+ // closed queue push fails
+ boost::concurrent::sync_priority_queue<int> q;
+ q.close();
+ try {
+ q.push(1);
+ BOOST_TEST(false); // fixme
+ } catch (...) {
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(q.closed());
+ }
+ }
+ {
+ // 1-element closed queue pull succeed
+ boost::concurrent::sync_priority_queue<int> q;
+ q.push(1);
+ q.close();
+ int i;
+ i=q.pull();
+ BOOST_TEST_EQ(i, 1);
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(q.closed());
+ }
+ {
+ // 1-element closed queue wait_pull succeed
+ boost::concurrent::sync_priority_queue<int> q;
+ q.push(1);
+ q.close();
+ int i;
+ BOOST_TEST(boost::queue_op_status::success == q.wait_pull(i));
+ BOOST_TEST_EQ(i, 1);
+ BOOST_TEST(q.empty());
+ BOOST_TEST(! q.full());
+ BOOST_TEST_EQ(q.size(), 0u);
+ BOOST_TEST(q.closed());
+ }
+ {
+ // closed empty queue wait_pull fails
+ boost::concurrent::sync_priority_queue<int> q;
+ q.close();
+ BOOST_TEST(q.empty());
+ BOOST_TEST(q.closed());
+ int i;
+ BOOST_TEST(boost::queue_op_status::closed == q.wait_pull(i));
+ BOOST_TEST(q.empty());
+ BOOST_TEST(q.closed());
+ }
+ return boost::report_errors();
+}
diff --git a/libs/thread/test/sync/mutual_exclusion/sync_pq/tq_single_thread_pass.cpp b/libs/thread/test/sync/mutual_exclusion/sync_pq/tq_single_thread_pass.cpp
new file mode 100644
index 000000000..dd4dfc17f
--- /dev/null
+++ b/libs/thread/test/sync/mutual_exclusion/sync_pq/tq_single_thread_pass.cpp
@@ -0,0 +1,155 @@
+// Copyright (C) 2014 Ian Forbed
+// Copyright (C) 2014 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+
+#include <boost/config.hpp>
+#if ! defined BOOST_NO_CXX11_DECLTYPE
+#define BOOST_RESULT_OF_USE_DECLTYPE
+#endif
+
+#define BOOST_THREAD_VERSION 4
+#define BOOST_THREAD_PROVIDES_EXECUTORS
+
+#include <boost/thread.hpp>
+#include <boost/chrono.hpp>
+#include <boost/function.hpp>
+#include <boost/thread/concurrent_queues/sync_timed_queue.hpp>
+#include <boost/thread/executors/work.hpp>
+
+#include <boost/core/lightweight_test.hpp>
+
+using namespace boost::chrono;
+
+typedef boost::concurrent::sync_timed_queue<int> sync_tq;
+
+void test_all()
+{
+ sync_tq pq;
+ BOOST_TEST(pq.empty());
+ BOOST_TEST(!pq.closed());
+ BOOST_TEST_EQ(pq.size(), std::size_t(0));
+
+ for(int i = 1; i <= 5; i++){
+ pq.push(i, milliseconds(i*100));
+ BOOST_TEST(!pq.empty());
+ BOOST_TEST_EQ(pq.size(), std::size_t(i));
+ }
+
+ for(int i = 6; i <= 10; i++){
+ pq.push(i,steady_clock::now() + milliseconds(i*100));
+ BOOST_TEST(!pq.empty());
+ BOOST_TEST_EQ(pq.size(), std::size_t(i));
+ }
+
+ for(int i = 1; i <= 10; i++){
+ int val = pq.pull();
+ BOOST_TEST_EQ(val, i);
+ }
+
+ int val;
+ boost::queue_op_status st = pq.nonblocking_pull(val);
+ BOOST_TEST(boost::queue_op_status::empty == st);
+
+ BOOST_TEST(pq.empty());
+ pq.close();
+ BOOST_TEST(pq.closed());
+}
+
+void test_all_with_try()
+{
+ sync_tq pq;
+ BOOST_TEST(pq.empty());
+ BOOST_TEST(!pq.closed());
+ BOOST_TEST_EQ(pq.size(), std::size_t(0));
+
+ for(int i = 1; i <= 5; i++){
+ boost::queue_op_status st = pq.try_push(i, milliseconds(i*100));
+ BOOST_TEST(st == boost::queue_op_status::success );
+ BOOST_TEST(!pq.empty());
+ BOOST_TEST_EQ(pq.size(), std::size_t(i));
+ }
+
+ for(int i = 6; i <= 10; i++){
+ boost::queue_op_status st = pq.try_push(i,steady_clock::now() + milliseconds(i*100));
+ BOOST_TEST(st == boost::queue_op_status::success );
+ BOOST_TEST(!pq.empty());
+ BOOST_TEST_EQ(pq.size(), std::size_t(i));
+ }
+
+ for(int i = 1; i <= 10; i++){
+ int val=0;
+ boost::queue_op_status st = pq.wait_pull(val);
+ BOOST_TEST(st == boost::queue_op_status::success );
+ BOOST_TEST_EQ(val, i);
+ }
+
+ int val;
+ boost::queue_op_status st = pq.nonblocking_pull(val);
+ BOOST_TEST(st == boost::queue_op_status::empty );
+
+ BOOST_TEST(pq.empty());
+ pq.close();
+ BOOST_TEST(pq.closed());
+}
+
+void func(steady_clock::time_point pushed, steady_clock::duration dur)
+{
+ BOOST_TEST(pushed + dur <= steady_clock::now());
+}
+void func2()
+{
+ BOOST_TEST(false);
+}
+
+/**
+ * This test ensures that when items come of the front of the queue
+ * that at least $dur has elapsed.
+ */
+void test_deque_times()
+{
+ boost::concurrent::sync_timed_queue<boost::function<void()> > tq;
+ for(int i = 0; i < 10; i++)
+ {
+ steady_clock::duration d = milliseconds(i*100);
+ boost::function<void()> fn = boost::bind(func, steady_clock::now(), d);
+ tq.push(fn, d);
+ }
+ while(!tq.empty())
+ {
+ boost::function<void()> fn = tq.pull();
+ fn();
+ }
+}
+
+/**
+ * This test ensures that when items come of the front of the queue
+ * that at least $dur has elapsed.
+ */
+#if 0
+void test_deque_times2()
+{
+ boost::concurrent::sync_timed_queue<boost::executors::work> tq;
+ for(int i = 0; i < 10; i++)
+ {
+ steady_clock::duration d = milliseconds(i*100);
+ tq.push(func2, d);
+ }
+ while(!tq.empty())
+ {
+ boost::executors::work fn = tq.pull();
+ fn();
+ }
+}
+#endif
+
+int main()
+{
+ test_all();
+ test_all_with_try();
+ test_deque_times();
+ //test_deque_times2(); // rt fails
+ return boost::report_errors();
+}
diff --git a/libs/thread/test/sync/mutual_exclusion/sync_queue/multi_thread_pass.cpp b/libs/thread/test/sync/mutual_exclusion/sync_queue/multi_thread_pass.cpp
index 0d6d1025d..556ca68e9 100644
--- a/libs/thread/test/sync/mutual_exclusion/sync_queue/multi_thread_pass.cpp
+++ b/libs/thread/test/sync/mutual_exclusion/sync_queue/multi_thread_pass.cpp
@@ -15,7 +15,6 @@
#endif
#define BOOST_THREAD_VERSION 4
-//#define BOOST_THREAD_QUEUE_DEPRECATE_OLD
#include <boost/thread/sync_queue.hpp>
#include <boost/thread/future.hpp>
@@ -23,50 +22,13 @@
#include <boost/detail/lightweight_test.hpp>
-#ifndef BOOST_THREAD_QUEUE_DEPRECATE_OLD
-struct call_push
-{
- boost::sync_queue<int> *q_;
- boost::barrier *go_;
-
- call_push(boost::sync_queue<int> *q, boost::barrier *go) :
- q_(q), go_(go)
- {
- }
- typedef void result_type;
- void operator()()
- {
- go_->count_down_and_wait();
- q_->push(42);
-
- }
-};
-
-struct call_pull
-{
- boost::sync_queue<int> *q_;
- boost::barrier *go_;
-
- call_pull(boost::sync_queue<int> *q, boost::barrier *go) :
- q_(q), go_(go)
- {
- }
- typedef int result_type;
- int operator()()
- {
- go_->count_down_and_wait();
- return q_->pull();
- }
-};
-#endif
-
template <typename ValueType>
-struct call_push_back
+struct call_push
{
boost::sync_queue<ValueType> *q_;
boost::barrier *go_;
- call_push_back(boost::sync_queue<ValueType> *q, boost::barrier *go) :
+ call_push(boost::sync_queue<ValueType> *q, boost::barrier *go) :
q_(q), go_(go)
{
}
@@ -74,17 +36,17 @@ struct call_push_back
void operator()()
{
go_->count_down_and_wait();
- q_->push_back(42);
+ q_->push(42);
}
};
template <typename ValueType>
-struct call_pull_front
+struct call_pull
{
boost::sync_queue<ValueType> *q_;
boost::barrier *go_;
- call_pull_front(boost::sync_queue<ValueType> *q, boost::barrier *go) :
+ call_pull(boost::sync_queue<ValueType> *q, boost::barrier *go) :
q_(q), go_(go)
{
}
@@ -92,17 +54,17 @@ struct call_pull_front
ValueType operator()()
{
go_->count_down_and_wait();
- return q_->pull_front();
+ return q_->pull();
}
};
template <typename ValueType>
-struct call_wait_pull_front
+struct call_wait_pull
{
boost::sync_queue<ValueType> *q_;
boost::barrier *go_;
- call_wait_pull_front(boost::sync_queue<ValueType> *q, boost::barrier *go) :
+ call_wait_pull(boost::sync_queue<ValueType> *q, boost::barrier *go) :
q_(q), go_(go)
{
}
@@ -110,11 +72,10 @@ struct call_wait_pull_front
boost::queue_op_status operator()(ValueType& v)
{
go_->wait();
- return q_->wait_pull_front(v);
+ return q_->wait_pull(v);
}
};
-#ifndef BOOST_THREAD_QUEUE_DEPRECATE_OLD
void test_concurrent_push_and_pull_on_empty_queue()
{
boost::sync_queue<int> q;
@@ -127,127 +88,9 @@ void test_concurrent_push_and_pull_on_empty_queue()
try
{
push_done=boost::async(boost::launch::async,
-#if ! defined BOOST_NO_CXX11_LAMBDAS
- [&q,&go]()
- {
- go.wait();
- q.push(42);
- }
-#else
- call_push(&q,&go)
-#endif
- );
- pull_done=boost::async(boost::launch::async,
-#if ! defined BOOST_NO_CXX11_LAMBDAS
- [&q,&go]() -> int
- {
- go.wait();
- return q.pull();
- }
-#else
- call_pull(&q,&go)
-#endif
- );
-
- push_done.get();
- BOOST_TEST_EQ(pull_done.get(), 42);
- BOOST_TEST(q.empty());
- }
- catch (...)
- {
- BOOST_TEST(false);
- }
-}
-
-void test_concurrent_push_on_empty_queue()
-{
- boost::sync_queue<int> q;
- const unsigned int n = 3;
- boost::barrier go(n);
- boost::future<void> push_done[n];
-
- try
- {
- for (unsigned int i =0; i< n; ++i)
- push_done[i]=boost::async(boost::launch::async,
-#if ! defined BOOST_NO_CXX11_LAMBDAS
- [&q,&go]()
- {
- go.wait();
- q.push(42);
- }
-#else
- call_push(&q,&go)
-#endif
- );
-
- for (unsigned int i = 0; i < n; ++i)
- push_done[i].get();
-
- BOOST_TEST(!q.empty());
- for (unsigned int i =0; i< n; ++i)
- BOOST_TEST_EQ(q.pull(), 42);
- BOOST_TEST(q.empty());
-
- }
- catch (...)
- {
- BOOST_TEST(false);
- }
-}
-
-void test_concurrent_pull_on_queue()
-{
- boost::sync_queue<int> q;
- const unsigned int n = 3;
- boost::barrier go(n);
-
- boost::future<int> pull_done[n];
-
- try
- {
- for (unsigned int i =0; i< n; ++i)
- q.push(42);
-
- for (unsigned int i =0; i< n; ++i)
- pull_done[i]=boost::async(boost::launch::async,
-#if ! defined BOOST_NO_CXX11_LAMBDAS
- [&q,&go]() -> int
- {
- go.wait();
- return q.pull();
- }
-#else
- call_pull(&q,&go)
-#endif
- );
-
- for (unsigned int i = 0; i < n; ++i)
- BOOST_TEST_EQ(pull_done[i].get(), 42);
- BOOST_TEST(q.empty());
- }
- catch (...)
- {
- BOOST_TEST(false);
- }
-}
-#endif
-
-void test_concurrent_push_back_and_pull_front_on_empty_queue()
-{
- boost::sync_queue<int> q;
-
- boost::barrier go(2);
-
- boost::future<void> push_done;
- boost::future<int> pull_done;
-
- try
- {
- push_done=boost::async(boost::launch::async,
- call_push_back<int>(&q,&go));
+ call_push<int>(&q,&go));
pull_done=boost::async(boost::launch::async,
- call_pull_front<int>(&q,&go));
+ call_pull<int>(&q,&go));
push_done.get();
BOOST_TEST_EQ(pull_done.get(), 42);
@@ -260,7 +103,7 @@ void test_concurrent_push_back_and_pull_front_on_empty_queue()
}
#if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
-void test_concurrent_push_back_and_wait_pull_front_on_empty_queue()
+void test_concurrent_push_and_wait_pull_on_empty_queue()
{
boost::sync_queue<int> q;
const unsigned int n = 3;
@@ -273,11 +116,11 @@ void test_concurrent_push_back_and_wait_pull_front_on_empty_queue()
{
for (unsigned int i =0; i< n; ++i)
pull_done[i]=boost::async(boost::launch::async,
- call_wait_pull_front<int>(&q,&go),
+ call_wait_pull<int>(&q,&go),
boost::ref(results[i]));
for (unsigned int i =0; i< n; ++i)
- q.push_back(42);
+ q.push(42);
for (unsigned int i = 0; i < n; ++i) {
BOOST_TEST(pull_done[i].get() == boost::queue_op_status::success);
@@ -291,7 +134,7 @@ void test_concurrent_push_back_and_wait_pull_front_on_empty_queue()
}
}
-void test_concurrent_wait_pull_front_and_close_on_empty_queue()
+void test_concurrent_wait_pull_and_close_on_empty_queue()
{
boost::sync_queue<int> q;
const unsigned int n = 3;
@@ -304,7 +147,7 @@ void test_concurrent_wait_pull_front_and_close_on_empty_queue()
{
for (unsigned int i =0; i< n; ++i)
pull_done[i]=boost::async(boost::launch::async,
- call_wait_pull_front<int>(&q,&go),
+ call_wait_pull<int>(&q,&go),
boost::ref(results[i]));
q.close();
@@ -321,7 +164,7 @@ void test_concurrent_wait_pull_front_and_close_on_empty_queue()
}
#endif
-void test_concurrent_push_back_on_empty_queue()
+void test_concurrent_push_on_empty_queue()
{
boost::sync_queue<int> q;
const unsigned int n = 3;
@@ -332,7 +175,7 @@ void test_concurrent_push_back_on_empty_queue()
{
for (unsigned int i =0; i< n; ++i)
push_done[i]=boost::async(boost::launch::async,
- call_push_back<int>(&q,&go));
+ call_push<int>(&q,&go));
}
catch (...)
@@ -353,7 +196,7 @@ void test_concurrent_push_back_on_empty_queue()
{
BOOST_TEST(!q.empty());
for (unsigned int i =0; i< n; ++i)
- BOOST_TEST_EQ(q.pull_front(), 42);
+ BOOST_TEST_EQ(q.pull(), 42);
BOOST_TEST(q.empty());
}
@@ -363,7 +206,7 @@ void test_concurrent_push_back_on_empty_queue()
}
}
-void test_concurrent_pull_front_on_queue()
+void test_concurrent_pull_on_queue()
{
boost::sync_queue<int> q;
const unsigned int n = 3;
@@ -374,7 +217,7 @@ void test_concurrent_pull_front_on_queue()
try
{
for (unsigned int i =0; i< n; ++i)
- q.push_back(42);
+ q.push(42);
for (unsigned int i =0; i< n; ++i)
pull_done[i]=boost::async(boost::launch::async,
@@ -382,10 +225,10 @@ void test_concurrent_pull_front_on_queue()
[&q,&go]() -> int
{
go.wait();
- return q.pull_front();
+ return q.pull();
}
#else
- call_pull_front<int>(&q,&go)
+ call_pull<int>(&q,&go)
#endif
);
@@ -401,18 +244,13 @@ void test_concurrent_pull_front_on_queue()
int main()
{
-#ifndef BOOST_THREAD_QUEUE_DEPRECATE_OLD
test_concurrent_push_and_pull_on_empty_queue();
- test_concurrent_push_on_empty_queue();
- test_concurrent_pull_on_queue();
-#endif
- test_concurrent_push_back_and_pull_front_on_empty_queue();
#if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
- test_concurrent_push_back_and_wait_pull_front_on_empty_queue();
- test_concurrent_wait_pull_front_and_close_on_empty_queue();
+ test_concurrent_push_and_wait_pull_on_empty_queue();
+ test_concurrent_wait_pull_and_close_on_empty_queue();
#endif
- test_concurrent_push_back_on_empty_queue();
- test_concurrent_pull_front_on_queue();
+ test_concurrent_push_on_empty_queue();
+ test_concurrent_pull_on_queue();
return boost::report_errors();
}
diff --git a/libs/thread/test/sync/mutual_exclusion/sync_queue/single_thread_pass.cpp b/libs/thread/test/sync/mutual_exclusion/sync_queue/single_thread_pass.cpp
index 0d788d88c..8f47ec82a 100644
--- a/libs/thread/test/sync/mutual_exclusion/sync_queue/single_thread_pass.cpp
+++ b/libs/thread/test/sync/mutual_exclusion/sync_queue/single_thread_pass.cpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2013 Vicente J. Botet Escriba
+// Copyright (C) 2013,2015 Vicente J. Botet Escriba
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -10,7 +10,6 @@
// sync_queue();
#define BOOST_THREAD_VERSION 4
-//#define BOOST_THREAD_QUEUE_DEPRECATE_OLD
#include <boost/thread/sync_queue.hpp>
@@ -47,79 +46,8 @@ int main()
BOOST_TEST_EQ(q.size(), 0u);
BOOST_TEST(! q.closed());
}
-#ifndef BOOST_THREAD_QUEUE_DEPRECATE_OLD
- {
- // empty queue try_pull fails
- boost::sync_queue<int> q;
- int i;
- BOOST_TEST(! q.try_pull(i));
- BOOST_TEST(q.empty());
- BOOST_TEST(! q.full());
- BOOST_TEST_EQ(q.size(), 0u);
- BOOST_TEST(! q.closed());
- }
- {
- // empty queue try_pull fails
- boost::sync_queue<int> q;
- BOOST_TEST(! q.try_pull());
- BOOST_TEST(q.empty());
- BOOST_TEST(! q.full());
- BOOST_TEST_EQ(q.size(), 0u);
- BOOST_TEST(! q.closed());
- }
- {
- // empty queue push rvalue/copyable succeeds
- boost::sync_queue<int> q;
- q.push(1);
- BOOST_TEST(! q.empty());
- BOOST_TEST(! q.full());
- BOOST_TEST_EQ(q.size(), 1u);
- BOOST_TEST(! q.closed());
- }
- {
- // empty queue push lvalue/copyable succeeds
- boost::sync_queue<int> q;
- int i;
- q.push(i);
- BOOST_TEST(! q.empty());
- BOOST_TEST(! q.full());
- BOOST_TEST_EQ(q.size(), 1u);
- BOOST_TEST(! q.closed());
- }
-#endif
-
- {
- // empty queue try_pull fails
- boost::sync_queue<int> q;
- int i;
- BOOST_TEST( boost::queue_op_status::empty == q.try_pull_front(i));
- BOOST_TEST(q.empty());
- BOOST_TEST(! q.full());
- BOOST_TEST_EQ(q.size(), 0u);
- BOOST_TEST(! q.closed());
- }
- {
- // empty queue push rvalue/copyable succeeds
- boost::sync_queue<int> q;
- q.push_back(1);
- BOOST_TEST(! q.empty());
- BOOST_TEST(! q.full());
- BOOST_TEST_EQ(q.size(), 1u);
- BOOST_TEST(! q.closed());
- }
- {
- // empty queue push lvalue/copyable succeeds
- boost::sync_queue<int> q;
- int i;
- q.push_back(i);
- BOOST_TEST(! q.empty());
- BOOST_TEST(! q.full());
- BOOST_TEST_EQ(q.size(), 1u);
- BOOST_TEST(! q.closed());
- }
-#ifndef BOOST_THREAD_QUEUE_DEPRECATE_OLD
-#if 0
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
{
// empty queue push rvalue/non_copyable succeeds
boost::sync_queue<non_copyable> q;
@@ -164,68 +92,7 @@ int main()
{
// empty queue try_push rvalue/copyable succeeds
boost::sync_queue<int> q;
- BOOST_TEST(q.try_push(1));
- BOOST_TEST(! q.empty());
- BOOST_TEST(! q.full());
- BOOST_TEST_EQ(q.size(), 1u);
- BOOST_TEST(! q.closed());
- }
- {
- // empty queue try_push rvalue/copyable succeeds
- boost::sync_queue<int> q;
- BOOST_TEST(q.try_push(1));
- BOOST_TEST(! q.empty());
- BOOST_TEST(! q.full());
- BOOST_TEST_EQ(q.size(), 1u);
- BOOST_TEST(! q.closed());
- }
-#endif
-#if 0
- {
- // empty queue push rvalue/non_copyable succeeds
- boost::sync_queue<non_copyable> q;
- q.push_back(non_copyable(1));
- BOOST_TEST(! q.empty());
- BOOST_TEST(! q.full());
- BOOST_TEST_EQ(q.size(), 1u);
- BOOST_TEST(! q.closed());
- }
-#endif
- {
- // empty queue push rvalue/non_copyable succeeds
- boost::sync_queue<non_copyable> q;
- non_copyable nc(1);
- q.push_back(boost::move(nc));
- BOOST_TEST(! q.empty());
- BOOST_TEST(! q.full());
- BOOST_TEST_EQ(q.size(), 1u);
- BOOST_TEST(! q.closed());
- }
-
- {
- // empty queue push rvalue succeeds
- boost::sync_queue<int> q;
- q.push_back(1);
- q.push_back(2);
- BOOST_TEST(! q.empty());
- BOOST_TEST(! q.full());
- BOOST_TEST_EQ(q.size(), 2u);
- BOOST_TEST(! q.closed());
- }
- {
- // empty queue push lvalue succeeds
- boost::sync_queue<int> q;
- int i;
- q.push_back(i);
- BOOST_TEST(! q.empty());
- BOOST_TEST(! q.full());
- BOOST_TEST_EQ(q.size(), 1u);
- BOOST_TEST(! q.closed());
- }
- {
- // empty queue try_push rvalue/copyable succeeds
- boost::sync_queue<int> q;
- BOOST_TEST(boost::queue_op_status::success == q.try_push_back(1));
+ BOOST_TEST(boost::queue_op_status::success == q.try_push(1));
BOOST_TEST(! q.empty());
BOOST_TEST(! q.full());
BOOST_TEST_EQ(q.size(), 1u);
@@ -234,60 +101,18 @@ int main()
{
// empty queue try_push rvalue/copyable succeeds
boost::sync_queue<int> q;
- BOOST_TEST(boost::queue_op_status::success == q.try_push_back(1));
- BOOST_TEST(! q.empty());
- BOOST_TEST(! q.full());
- BOOST_TEST_EQ(q.size(), 1u);
- BOOST_TEST(! q.closed());
- }
-#ifndef BOOST_THREAD_QUEUE_DEPRECATE_OLD
-#if 0
- {
- // empty queue try_push rvalue/non-copyable succeeds
- boost::sync_queue<non_copyable> q;
- BOOST_TEST(q.try_push(non_copyable()));
- BOOST_TEST(! q.empty());
- BOOST_TEST(! q.full());
- BOOST_TEST_EQ(q.size(), 1u);
- BOOST_TEST(! q.closed());
- }
-#endif
- {
- // empty queue try_push rvalue/non-copyable succeeds
- boost::sync_queue<non_copyable> q;
- non_copyable nc(1);
- BOOST_TEST(q.try_push(boost::move(nc)));
+ BOOST_TEST(boost::queue_op_status::success == q.try_push(1));
BOOST_TEST(! q.empty());
BOOST_TEST(! q.full());
BOOST_TEST_EQ(q.size(), 1u);
BOOST_TEST(! q.closed());
}
- {
- // empty queue try_push lvalue succeeds
- boost::sync_queue<int> q;
- int i=1;
- BOOST_TEST(q.try_push(i));
- BOOST_TEST(! q.empty());
- BOOST_TEST(! q.full());
- BOOST_TEST_EQ(q.size(), 1u);
- BOOST_TEST(! q.closed());
- }
- {
- // empty queue try_push rvalue succeeds
- boost::sync_queue<int> q;
- BOOST_TEST(q.try_push(boost::no_block, 1));
- BOOST_TEST(! q.empty());
- BOOST_TEST(! q.full());
- BOOST_TEST_EQ(q.size(), 1u);
- BOOST_TEST(! q.closed());
- }
-#endif
-#if 0
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
{
// empty queue try_push rvalue/non-copyable succeeds
boost::sync_queue<non_copyable> q;
- BOOST_TEST(boost::queue_op_status::success ==q.try_push_back(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);
@@ -298,7 +123,7 @@ int main()
// empty queue try_push rvalue/non-copyable succeeds
boost::sync_queue<non_copyable> q;
non_copyable nc(1);
- BOOST_TEST(boost::queue_op_status::success == q.try_push_back(boost::move(nc)));
+ BOOST_TEST(boost::queue_op_status::success == q.try_push(boost::move(nc)));
BOOST_TEST(! q.empty());
BOOST_TEST(! q.full());
BOOST_TEST_EQ(q.size(), 1u);
@@ -309,7 +134,7 @@ int main()
// empty queue try_push lvalue succeeds
boost::sync_queue<int> q;
int i=1;
- BOOST_TEST(boost::queue_op_status::success == q.try_push_back(i));
+ BOOST_TEST(boost::queue_op_status::success == q.try_push(i));
BOOST_TEST(! q.empty());
BOOST_TEST(! q.full());
BOOST_TEST_EQ(q.size(), 1u);
@@ -318,19 +143,18 @@ int main()
{
// empty queue try_push rvalue succeeds
boost::sync_queue<int> q;
- BOOST_TEST(boost::queue_op_status::success == q.nonblocking_push_back(1));
+ 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());
}
-#ifndef BOOST_THREAD_QUEUE_DEPRECATE_OLD
-#if 0
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
{
- // empty queue try_push rvalue/non-copyable succeeds
+ // empty queue nonblocking_push rvalue/non-copyable succeeds
boost::sync_queue<non_copyable> q;
- BOOST_TEST(q.try_push(boost::no_block, non_copyable(1)));
+ BOOST_TEST(boost::queue_op_status::success == q.nonblocking_push(non_copyable(1)));
BOOST_TEST(! q.empty());
BOOST_TEST(! q.full());
BOOST_TEST_EQ(q.size(), 1u);
@@ -338,10 +162,10 @@ int main()
}
#endif
{
- // empty queue try_push rvalue/non-copyable succeeds
+ // empty queue nonblocking_push rvalue/non-copyable succeeds
boost::sync_queue<non_copyable> q;
non_copyable nc(1);
- BOOST_TEST(q.try_push(boost::no_block, boost::move(nc)));
+ 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);
@@ -400,7 +224,7 @@ int main()
boost::sync_queue<int> q;
q.push(1);
int i;
- BOOST_TEST(q.try_pull(i));
+ BOOST_TEST(boost::queue_op_status::success == q.try_pull(i));
BOOST_TEST_EQ(i, 1);
BOOST_TEST(q.empty());
BOOST_TEST(! q.full());
@@ -413,7 +237,7 @@ int main()
non_copyable nc1(1);
q.push(boost::move(nc1));
non_copyable nc(2);
- BOOST_TEST(q.try_pull(nc));
+ BOOST_TEST(boost::queue_op_status::success == q.try_pull(nc));
BOOST_TEST_EQ(nc, nc1);
BOOST_TEST(q.empty());
BOOST_TEST(! q.full());
@@ -421,11 +245,11 @@ int main()
BOOST_TEST(! q.closed());
}
{
- // 1-element queue try_pull succeed
+ // 1-element queue nonblocking_pull succeed
boost::sync_queue<int> q;
q.push(1);
int i;
- BOOST_TEST(q.try_pull(boost::no_block, i));
+ BOOST_TEST(boost::queue_op_status::success == q.nonblocking_pull(i));
BOOST_TEST_EQ(i, 1);
BOOST_TEST(q.empty());
BOOST_TEST(! q.full());
@@ -433,177 +257,12 @@ int main()
BOOST_TEST(! q.closed());
}
{
- // 1-element queue try_pull succeed
+ // 1-element queue nonblocking_pull succeed
boost::sync_queue<non_copyable> q;
non_copyable nc1(1);
q.push(boost::move(nc1));
non_copyable nc(2);
- BOOST_TEST(q.try_pull(boost::no_block, nc));
- BOOST_TEST_EQ(nc, nc1);
- BOOST_TEST(q.empty());
- BOOST_TEST(! q.full());
- BOOST_TEST_EQ(q.size(), 0u);
- BOOST_TEST(! q.closed());
- }
- {
- // 1-element queue try_pull succeed
- boost::sync_queue<int> q;
- q.push(1);
- boost::shared_ptr<int> i = q.try_pull();
- BOOST_TEST_EQ(*i, 1);
- BOOST_TEST(q.empty());
- BOOST_TEST(! q.full());
- BOOST_TEST_EQ(q.size(), 0u);
- BOOST_TEST(! q.closed());
- }
-
- {
- // closed invariants
- boost::sync_queue<int> q;
- q.close();
- BOOST_TEST(q.empty());
- BOOST_TEST(! q.full());
- BOOST_TEST_EQ(q.size(), 0u);
- BOOST_TEST(q.closed());
- }
- {
- // closed queue push fails
- boost::sync_queue<int> q;
- q.close();
- try {
- q.push(1);
- BOOST_TEST(false);
- } catch (...) {
- BOOST_TEST(q.empty());
- BOOST_TEST(! q.full());
- BOOST_TEST_EQ(q.size(), 0u);
- BOOST_TEST(q.closed());
- }
- }
- {
- // closed empty queue try_pull_front closed
- boost::sync_queue<int> q;
- q.close();
- int i;
- BOOST_TEST(boost::queue_op_status::closed == q.try_pull_front(i));
- BOOST_TEST(q.empty());
- BOOST_TEST(! q.full());
- BOOST_TEST_EQ(q.size(), 0u);
- BOOST_TEST(q.closed());
- }
- {
- // closed empty queue nonblocking_pull_front closed
- boost::sync_queue<int> q;
- q.close();
- int i;
- BOOST_TEST(boost::queue_op_status::closed == q.nonblocking_pull_front(i));
- BOOST_TEST(q.empty());
- BOOST_TEST(! q.full());
- BOOST_TEST_EQ(q.size(), 0u);
- BOOST_TEST(q.closed());
- }
- {
- // 1-element closed queue pull succeed
- boost::sync_queue<int> q;
- q.push(1);
- q.close();
- int i;
- q.pull(i);
- BOOST_TEST_EQ(i, 1);
- BOOST_TEST(q.empty());
- BOOST_TEST(! q.full());
- BOOST_TEST_EQ(q.size(), 0u);
- BOOST_TEST(q.closed());
- }
-#endif
-#if 0
- {
- // empty queue nonblocking_push_back rvalue/non-copyable succeeds
- boost::sync_queue<non_copyable> q;
- BOOST_TEST(boost::queue_op_status::success == q.nonblocking_push_back(non_copyable(1)));
- BOOST_TEST(! q.empty());
- BOOST_TEST(! q.full());
- BOOST_TEST_EQ(q.size(), 1u);
- BOOST_TEST(! q.closed());
- }
-#endif
- {
- // empty queue nonblocking_push_back rvalue/non-copyable succeeds
- boost::sync_queue<non_copyable> q;
- non_copyable nc(1);
- BOOST_TEST(boost::queue_op_status::success == q.nonblocking_push_back(boost::move(nc)));
- BOOST_TEST(! q.empty());
- BOOST_TEST(! q.full());
- BOOST_TEST_EQ(q.size(), 1u);
- BOOST_TEST(! q.closed());
- }
- {
- // 1-element queue pull_front succeed
- boost::sync_queue<int> q;
- q.push_back(1);
- int i;
- q.pull_front(i);
- BOOST_TEST_EQ(i, 1);
- BOOST_TEST(q.empty());
- BOOST_TEST(! q.full());
- BOOST_TEST_EQ(q.size(), 0u);
- BOOST_TEST(! q.closed());
- }
- {
- // 1-element queue pull_front succeed
- boost::sync_queue<non_copyable> q;
- non_copyable nc1(1);
- q.push_back(boost::move(nc1));
- non_copyable nc2(2);
- q.pull_front(nc2);
- BOOST_TEST_EQ(nc1, nc2);
- BOOST_TEST(q.empty());
- BOOST_TEST(! q.full());
- BOOST_TEST_EQ(q.size(), 0u);
- BOOST_TEST(! q.closed());
- }
- {
- // 1-element queue pull_front succeed
- boost::sync_queue<int> q;
- q.push_back(1);
- int i = q.pull_front();
- BOOST_TEST_EQ(i, 1);
- BOOST_TEST(q.empty());
- BOOST_TEST(! q.full());
- BOOST_TEST_EQ(q.size(), 0u);
- BOOST_TEST(! q.closed());
- }
- {
- // 1-element queue pull_front succeed
- boost::sync_queue<non_copyable> q;
- non_copyable nc1(1);
- q.push_back(boost::move(nc1));
- non_copyable nc = q.pull_front();
- BOOST_TEST_EQ(nc, nc1);
- BOOST_TEST(q.empty());
- BOOST_TEST(! q.full());
- BOOST_TEST_EQ(q.size(), 0u);
- BOOST_TEST(! q.closed());
- }
- {
- // 1-element queue try_pull_front succeed
- boost::sync_queue<int> q;
- q.push_back(1);
- int i;
- BOOST_TEST(boost::queue_op_status::success == q.try_pull_front(i));
- BOOST_TEST_EQ(i, 1);
- BOOST_TEST(q.empty());
- BOOST_TEST(! q.full());
- BOOST_TEST_EQ(q.size(), 0u);
- BOOST_TEST(! q.closed());
- }
- {
- // 1-element queue try_pull_front succeed
- boost::sync_queue<non_copyable> q;
- non_copyable nc1(1);
- q.push_back(boost::move(nc1));
- non_copyable nc(2);
- BOOST_TEST(boost::queue_op_status::success == q.try_pull_front(nc));
+ BOOST_TEST(boost::queue_op_status::success == q.nonblocking_pull(nc));
BOOST_TEST_EQ(nc, nc1);
BOOST_TEST(q.empty());
BOOST_TEST(! q.full());
@@ -611,37 +270,12 @@ int main()
BOOST_TEST(! q.closed());
}
{
- // 1-element queue nonblocking_pull_front succeed
- boost::sync_queue<int> q;
- q.push_back(1);
- int i;
- BOOST_TEST(boost::queue_op_status::success == q.nonblocking_pull_front(i));
- BOOST_TEST_EQ(i, 1);
- BOOST_TEST(q.empty());
- BOOST_TEST(! q.full());
- BOOST_TEST_EQ(q.size(), 0u);
- BOOST_TEST(! q.closed());
- }
- {
- // 1-element queue nonblocking_pull_front succeed
+ // 1-element queue wait_pull succeed
boost::sync_queue<non_copyable> q;
non_copyable nc1(1);
- q.push_back(boost::move(nc1));
- non_copyable nc(2);
- BOOST_TEST(boost::queue_op_status::success == q.nonblocking_pull_front(nc));
- BOOST_TEST_EQ(nc, nc1);
- BOOST_TEST(q.empty());
- BOOST_TEST(! q.full());
- BOOST_TEST_EQ(q.size(), 0u);
- BOOST_TEST(! q.closed());
- }
- {
- // 1-element queue wait_pull_front succeed
- boost::sync_queue<non_copyable> q;
- non_copyable nc1(1);
- q.push_back(boost::move(nc1));
+ q.push(boost::move(nc1));
non_copyable nc(2);
- BOOST_TEST(boost::queue_op_status::success == q.wait_pull_front(nc));
+ BOOST_TEST(boost::queue_op_status::success == q.wait_pull(nc));
BOOST_TEST_EQ(nc, nc1);
BOOST_TEST(q.empty());
BOOST_TEST(! q.full());
@@ -649,11 +283,11 @@ int main()
BOOST_TEST(! q.closed());
}
{
- // 1-element queue wait_pull_front succeed
+ // 1-element queue wait_pull succeed
boost::sync_queue<int> q;
- q.push_back(1);
+ q.push(1);
int i;
- BOOST_TEST(boost::queue_op_status::success == q.wait_pull_front(i));
+ BOOST_TEST(boost::queue_op_status::success == q.wait_pull(i));
BOOST_TEST_EQ(i, 1);
BOOST_TEST(q.empty());
BOOST_TEST(! q.full());
@@ -661,12 +295,12 @@ int main()
BOOST_TEST(! q.closed());
}
{
- // 1-element queue wait_pull_front succeed
+ // 1-element queue wait_pull succeed
boost::sync_queue<non_copyable> q;
non_copyable nc1(1);
- q.push_back(boost::move(nc1));
+ q.push(boost::move(nc1));
non_copyable nc(2);
- BOOST_TEST(boost::queue_op_status::success == q.wait_pull_front(nc));
+ BOOST_TEST(boost::queue_op_status::success == q.wait_pull(nc));
BOOST_TEST_EQ(nc, nc1);
BOOST_TEST(q.empty());
BOOST_TEST(! q.full());
@@ -688,7 +322,7 @@ int main()
boost::sync_queue<int> q;
q.close();
try {
- q.push_back(1);
+ q.push(1);
BOOST_TEST(false);
} catch (...) {
BOOST_TEST(q.empty());
@@ -700,10 +334,10 @@ int main()
{
// 1-element closed queue pull succeed
boost::sync_queue<int> q;
- q.push_back(1);
+ q.push(1);
q.close();
int i;
- q.pull_front(i);
+ q.pull(i);
BOOST_TEST_EQ(i, 1);
BOOST_TEST(q.empty());
BOOST_TEST(! q.full());
@@ -711,12 +345,12 @@ int main()
BOOST_TEST(q.closed());
}
{
- // 1-element closed queue wait_pull_front succeed
+ // 1-element closed queue wait_pull succeed
boost::sync_queue<int> q;
- q.push_back(1);
+ q.push(1);
q.close();
int i;
- BOOST_TEST(boost::queue_op_status::success == q.wait_pull_front(i));
+ BOOST_TEST(boost::queue_op_status::success == q.wait_pull(i));
BOOST_TEST_EQ(i, 1);
BOOST_TEST(q.empty());
BOOST_TEST(! q.full());
@@ -724,13 +358,13 @@ int main()
BOOST_TEST(q.closed());
}
{
- // closed empty queue wait_pull_front fails
+ // closed empty queue wait_pull fails
boost::sync_queue<int> q;
q.close();
BOOST_TEST(q.empty());
BOOST_TEST(q.closed());
int i;
- BOOST_TEST(boost::queue_op_status::closed == q.wait_pull_front(i));
+ BOOST_TEST(boost::queue_op_status::closed == q.wait_pull(i));
BOOST_TEST(q.empty());
BOOST_TEST(q.closed());
}
diff --git a/libs/thread/test/sync/mutual_exclusion/with_lock_guard/with_lock_guard_bind.cpp b/libs/thread/test/sync/mutual_exclusion/with_lock_guard/with_lock_guard_bind.cpp
index 58ec01ab4..2da08c2f4 100644
--- a/libs/thread/test/sync/mutual_exclusion/with_lock_guard/with_lock_guard_bind.cpp
+++ b/libs/thread/test/sync/mutual_exclusion/with_lock_guard/with_lock_guard_bind.cpp
@@ -72,7 +72,7 @@ void test_bind() {
BOOST_TEST(c == 345);
}
-#if defined(BOOST_NO_VARIADIC_TEMPLATES)
+#if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
void test_bind_non_const() {
std::cout << "c++11 variadic templates disabled" << std::endl;
}
diff --git a/libs/thread/test/test_10340.cpp b/libs/thread/test/test_10340.cpp
index 50d2aa0d0..5311e8210 100644
--- a/libs/thread/test/test_10340.cpp
+++ b/libs/thread/test/test_10340.cpp
@@ -1,3 +1,8 @@
+// Copyright (C) 2014 Vicente Botet
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
#define BOOST_THREAD_VERSION 4
#include <boost/thread/future.hpp>
diff --git a/libs/thread/test/test_10963.cpp b/libs/thread/test/test_10963.cpp
new file mode 100644
index 000000000..b918b55d3
--- /dev/null
+++ b/libs/thread/test/test_10963.cpp
@@ -0,0 +1,44 @@
+// Copyright (C) 2014 Vicente Botet
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+#define BOOST_THREAD_VERSION 4
+#include <boost/config.hpp>
+#if ! defined BOOST_NO_CXX11_DECLTYPE
+#define BOOST_RESULT_OF_USE_DECLTYPE
+#endif
+
+#include <boost/thread/future.hpp>
+#include <boost/static_assert.hpp>
+
+
+struct TestCallback
+{
+ typedef boost::future<void> result_type;
+
+ result_type operator()(boost::future<void> future) const
+ {
+ future.get();
+ return boost::make_ready_future();
+ }
+
+ result_type operator()(boost::future<boost::future<void> > future) const
+ {
+ future.get();
+ return boost::make_ready_future();
+ }
+};
+
+int main()
+{
+#if ! defined BOOST_NO_CXX11_DECLTYPE && ! defined BOOST_NO_CXX11_AUTO_DECLARATIONS
+ boost::promise<void> test_promise;
+ boost::future<void> test_future(test_promise.get_future());
+ auto f1 = test_future.then(TestCallback());
+ BOOST_STATIC_ASSERT(std::is_same<decltype(f1), boost::future<boost::future<void> > >::value);
+ auto f2 = f1.then(TestCallback());
+ BOOST_STATIC_ASSERT(std::is_same<decltype(f2), boost::future<boost::future<void> > >::value);
+#endif
+ return 0;
+}
diff --git a/libs/thread/test/test_10964.cpp b/libs/thread/test/test_10964.cpp
new file mode 100644
index 000000000..b8cc7b5c0
--- /dev/null
+++ b/libs/thread/test/test_10964.cpp
@@ -0,0 +1,76 @@
+// Copyright (C) 2015 Vicente Botet
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+#define BOOST_THREAD_VERSION 4
+#include <boost/config.hpp>
+#if ! defined BOOST_NO_CXX11_DECLTYPE
+#define BOOST_RESULT_OF_USE_DECLTYPE
+#endif
+
+#include <boost/thread/future.hpp>
+#include <boost/static_assert.hpp>
+
+struct TestCallback
+{
+ typedef boost::future<void> result_type;
+
+ result_type operator()(boost::future<void> future) const
+ {
+ future.get();
+ return boost::make_ready_future();
+ }
+
+ result_type operator()(boost::future<boost::future<void> > future) const
+ {
+ future.get();
+ return boost::make_ready_future();
+ }
+};
+
+void p1()
+{
+}
+
+int main()
+{
+#if ! defined BOOST_NO_CXX11_DECLTYPE && ! defined BOOST_NO_CXX11_AUTO_DECLARATIONS
+ std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
+ {
+ auto f1 = boost::make_ready_future().then(TestCallback());
+ BOOST_STATIC_ASSERT(std::is_same<decltype(f1), boost::future<boost::future<void> > >::value);
+ f1.wait();
+ }
+ std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
+ {
+ auto f1 = boost::make_ready_future().then(TestCallback());
+ BOOST_STATIC_ASSERT(std::is_same<decltype(f1), boost::future<boost::future<void> > >::value);
+ auto f2 = f1.unwrap();
+ BOOST_STATIC_ASSERT(std::is_same<decltype(f2), boost::future<void> >::value);
+ f2.wait();
+ }
+ std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
+ {
+ auto f1 = boost::make_ready_future().then(TestCallback());
+ BOOST_STATIC_ASSERT(std::is_same<decltype(f1), boost::future<boost::future<void> > >::value);
+ auto f2 = f1.unwrap();
+ BOOST_STATIC_ASSERT(std::is_same<decltype(f2), boost::future<void> >::value);
+ auto f3 = f2.then(TestCallback());
+ BOOST_STATIC_ASSERT(std::is_same<decltype(f1), boost::future<boost::future<void> > >::value);
+ f3.wait();
+ }
+ std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
+ {
+ boost::make_ready_future().then(
+ TestCallback()).unwrap().then(TestCallback()).get();
+ }
+ std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl;
+ {
+ boost::future<void> f = boost::async(p1);
+ f.then(
+ TestCallback()).unwrap().then(TestCallback()).get();
+ }
+#endif
+ return 0;
+}
diff --git a/libs/thread/test/test_11053.cpp b/libs/thread/test/test_11053.cpp
new file mode 100644
index 000000000..a8b6dfa97
--- /dev/null
+++ b/libs/thread/test/test_11053.cpp
@@ -0,0 +1,70 @@
+// Copyright (C) 2015 Vicente Botet
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+#define BOOST_THREAD_VERSION 4
+#include <boost/thread.hpp>
+#include <boost/thread/tss.hpp>
+#include <boost/shared_ptr.hpp>
+#include <iostream>
+
+struct A
+{
+ void DoWork()
+ {
+ std::cout << "A: doing work\n";
+ if (!m_ptr.get())
+ m_ptr.reset(new WorkSpace());
+ // do not very much
+ for (size_t i = 0; i < 10; ++i)
+ m_ptr->a += 10;
+ }
+
+private:
+ struct WorkSpace
+ {
+ int a;
+ WorkSpace() : a(0) {}
+ };
+ boost::thread_specific_ptr<WorkSpace> m_ptr;
+};
+
+struct B
+{
+ void DoWork()
+ {
+ std::cout << "B: doing work\n";
+ if (!m_ptr.get())
+ m_ptr.reset(new A());
+ m_ptr->DoWork();
+ }
+private:
+ boost::thread_specific_ptr<A> m_ptr;
+};
+
+struct C
+{
+ void DoWork()
+ {
+ std::cout << "C: doing work\n";
+ if (!m_ptr.get())
+ m_ptr.reset(new B());
+ m_ptr->DoWork();
+ }
+private:
+ boost::thread_specific_ptr<B> m_ptr;
+};
+
+int main(int ac, char** av)
+{
+ std::cout << "test starting\n";
+ boost::shared_ptr<C> p_C(new C);
+ boost::thread cWorker(&C::DoWork, p_C);
+ cWorker.join();
+ std::cout << "test stopping\n";
+ return 0;
+}
+
+
+
diff --git a/libs/thread/test/test_2309.cpp b/libs/thread/test/test_2309.cpp
index 1385a174a..09d92c30a 100755
--- a/libs/thread/test/test_2309.cpp
+++ b/libs/thread/test/test_2309.cpp
@@ -5,7 +5,7 @@
#define BOOST_THREAD_VERSION 2
#define BOOST_THREAD_PROVIDES_INTERRUPTIONS
-
+#define BOOST_TEST_MODULE Boost.Threads: 2309
#include <boost/test/unit_test.hpp>
#include <iostream>
@@ -40,7 +40,7 @@
}
}
- void test()
+ BOOST_AUTO_TEST_CASE(test)
{
try
{
@@ -61,14 +61,5 @@
}
}
-boost::unit_test_framework::test_suite* init_unit_test_suite(int, char*[])
-{
- boost::unit_test_framework::test_suite* tests =
- BOOST_TEST_SUITE("Boost.Threads: 2309");
-
- tests->add(BOOST_TEST_CASE(&test));
-
- return tests;
-}
diff --git a/libs/thread/test/test_2741.cpp b/libs/thread/test/test_2741.cpp
index 409a51f7b..793e68cdc 100644
--- a/libs/thread/test/test_2741.cpp
+++ b/libs/thread/test/test_2741.cpp
@@ -3,7 +3,7 @@
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#define BOOST_THREAD_VERSION 2
-
+#define BOOST_TEST_MODULE Boost.Threads: thread attributes test suite
#include <boost/thread/detail/config.hpp>
#include <boost/thread/thread_only.hpp>
@@ -29,7 +29,7 @@ void simple_thread()
test_value = 999;
}
-void test_native_handle()
+BOOST_AUTO_TEST_CASE(test_native_handle)
{
boost::thread_attributes attrs;
@@ -51,7 +51,7 @@ void test_native_handle()
}
-void test_stack_size()
+BOOST_AUTO_TEST_CASE(test_stack_size)
{
boost::thread_attributes attrs;
@@ -70,18 +70,8 @@ void do_test_creation_with_attrs()
BOOST_CHECK_EQUAL(test_value, 999);
}
-void test_creation_with_attrs()
+BOOST_AUTO_TEST_CASE(test_creation_with_attrs)
{
timed_test(&do_test_creation_with_attrs, 1);
}
-boost::unit_test_framework::test_suite* init_unit_test_suite(int, char*[])
-{
- boost::unit_test_framework::test_suite* test = BOOST_TEST_SUITE("Boost.Threads: thread attributes test suite");
-
- test->add(BOOST_TEST_CASE(test_native_handle));
- test->add(BOOST_TEST_CASE(test_stack_size));
- test->add(BOOST_TEST_CASE(test_creation_with_attrs));
-
- return test;
-}
diff --git a/libs/thread/test/test_9192.cpp b/libs/thread/test/test_9192.cpp
index ddc8b9266..c7aad7dd8 100755
--- a/libs/thread/test/test_9192.cpp
+++ b/libs/thread/test/test_9192.cpp
@@ -1,3 +1,8 @@
+// Copyright (C) 2014 Vicente Botet
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
#include <boost/interprocess/shared_memory_object.hpp>
#include <boost/interprocess/mapped_region.hpp>
#include <boost/thread.hpp>
diff --git a/libs/thread/test/test_9303.cpp b/libs/thread/test/test_9303.cpp
index a49758a1a..19bfc3eeb 100644
--- a/libs/thread/test/test_9303.cpp
+++ b/libs/thread/test/test_9303.cpp
@@ -1,3 +1,8 @@
+// Copyright (C) 2014 Vicente Botet
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
#define BOOST_THREAD_VERSION 4
#include <iostream>
#include <fstream>
@@ -81,7 +86,7 @@
#if defined EXAMPLE_3
//! Doesn't compile in C++03.
- //! error: variable ‘boost::packaged_task<std::basic_string<char>(std::basic_string<char>&)> example’ has initializer but incomplete type
+ //! error: variable âboost::packaged_task<std::basic_string<char>(std::basic_string<char>&)> exampleâ has initializer but incomplete type
{
boost::packaged_task<std::string(std::string&)> example(string_with_params);
diff --git a/libs/thread/test/test_9319.cpp b/libs/thread/test/test_9319.cpp
index 173f42729..9e5c1d935 100644
--- a/libs/thread/test/test_9319.cpp
+++ b/libs/thread/test/test_9319.cpp
@@ -24,18 +24,37 @@ void foo(IntPromise p)
void bar(boost::future<int> fooResult)
{
+ try {
std::cout << "bar" << std::endl;
int i = fooResult.get(); // Code hangs on this line (Due to future already being locked by the set_value call)
std::cout << "i: " << i << std::endl;
+ } catch(...) {
+ std::cout << __FILE__ << ":" << __LINE__ << std::endl;
+ }
}
int main()
{
+ std::cout << __FILE__ << ":" << __LINE__ << std::endl;
+ try {
IntPromise p(new boost::promise<int>());
boost::thread t(boost::bind(foo, p));
boost::future<int> f1 = p->get_future();
- //f1.then(launch::deferred, boost::bind(bar, _1));
f1.then(boost::launch::deferred, &bar);
t.join();
+ } catch(...) {
+ return 1;
+ }
+ std::cout << __FILE__ << ":" << __LINE__ << std::endl;
+ try {
+ IntPromise p(new boost::promise<int>());
+ boost::thread t(boost::bind(foo, p));
+ boost::future<int> f1 = p->get_future();
+ f1.then(boost::launch::async, &bar);
+ t.join();
+ } catch(...) {
+ return 2;
+ }
+ std::cout << __FILE__ << ":" << __LINE__ << std::endl;
}
diff --git a/libs/thread/test/test_9711.cpp b/libs/thread/test/test_9711.cpp
index a2095f663..d8fd8e3e8 100644
--- a/libs/thread/test/test_9711.cpp
+++ b/libs/thread/test/test_9711.cpp
@@ -1,3 +1,7 @@
+// Copyright (C) 2014 Vicente Botet
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#define BOOST_THREAD_PROVIDES_FUTURE
#define BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION
diff --git a/libs/thread/test/test_9856.cpp b/libs/thread/test/test_9856.cpp
new file mode 100644
index 000000000..918d232d5
--- /dev/null
+++ b/libs/thread/test/test_9856.cpp
@@ -0,0 +1,29 @@
+#include "boost/atomic.hpp"
+#include "boost/thread.hpp"
+#include <iostream>
+
+using namespace boost;
+
+int main() {
+ atomic<size_t> total(0), failures(0);
+
+#pragma omp parallel shared(total, failures) num_threads(1000)
+ {
+ mutex mtx;
+ condition_variable cond;
+ unique_lock<mutex> lk(mtx);
+ for (int i = 0; i < 500; i++) {
+ ++total;
+ if (cv_status::timeout != cond.wait_for(lk, chrono::milliseconds(10)))
+ ++failures;
+ }
+ }
+ if(failures)
+ std::cout << "There were " << failures << " failures out of " << total << " timed waits." << std::endl;
+ if((100*failures)/total>10)
+ {
+ std::cerr << "This exceeds 10%, so failing the test." << std::endl;
+ return 1;
+ }
+ return 0;
+} \ No newline at end of file
diff --git a/libs/thread/test/test_condition.cpp b/libs/thread/test/test_condition.cpp
index f37a95550..64d0871b7 100644
--- a/libs/thread/test/test_condition.cpp
+++ b/libs/thread/test/test_condition.cpp
@@ -7,7 +7,7 @@
#define BOOST_THREAD_VERSION 2
#define BOOST_THREAD_PROVIDES_INTERRUPTIONS
-
+#define BOOST_TEST_MODULE Boost.Threads: condition test suite
#include <boost/thread/detail/config.hpp>
#include <boost/thread/condition.hpp>
@@ -156,7 +156,7 @@ void do_test_condition_waits()
BOOST_CHECK_EQUAL(data.awoken, 5);
}
-void test_condition_waits()
+BOOST_AUTO_TEST_CASE(test_condition_waits)
{
// We should have already tested notify_one here, so
// a timed test with the default execution_monitor::use_condition
@@ -176,20 +176,8 @@ void do_test_condition_wait_is_a_interruption_point()
}
-void test_condition_wait_is_a_interruption_point()
+BOOST_AUTO_TEST_CASE(test_condition_wait_is_a_interruption_point)
{
timed_test(&do_test_condition_wait_is_a_interruption_point, 1);
}
-boost::unit_test::test_suite* init_unit_test_suite(int, char*[])
-{
- boost::unit_test::test_suite* test =
- BOOST_TEST_SUITE("Boost.Threads: condition test suite");
-
- test->add(BOOST_TEST_CASE(&test_condition_waits));
- test->add(BOOST_TEST_CASE(&test_condition_wait_is_a_interruption_point));
-
- return test;
-}
-
-
diff --git a/libs/thread/test/test_condition_notify_all.cpp b/libs/thread/test/test_condition_notify_all.cpp
index 944f94554..017ff28d1 100644
--- a/libs/thread/test/test_condition_notify_all.cpp
+++ b/libs/thread/test/test_condition_notify_all.cpp
@@ -4,7 +4,7 @@
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#define BOOST_THREAD_VERSION 2
-
+#define BOOST_TEST_MODULE Boost.Threads: condition_variable notify_all test suite
#include <boost/thread/detail/config.hpp>
#include <boost/thread/thread_only.hpp>
@@ -202,7 +202,7 @@ void do_test_notify_all_following_notify_one_wakes_all_threads()
thread3.join();
}
-void test_condition_notify_all()
+BOOST_AUTO_TEST_CASE(test_condition_notify_all)
{
timed_test(&do_test_condition_notify_all_wakes_from_wait, timeout_seconds);
timed_test(&do_test_condition_notify_all_wakes_from_wait_with_predicate, timeout_seconds);
@@ -213,14 +213,4 @@ void test_condition_notify_all()
}
-boost::unit_test::test_suite* init_unit_test_suite(int, char*[])
-{
- boost::unit_test::test_suite* test =
- BOOST_TEST_SUITE("Boost.Threads: condition test suite");
-
- test->add(BOOST_TEST_CASE(&test_condition_notify_all));
-
- return test;
-}
-
diff --git a/libs/thread/test/test_condition_notify_one.cpp b/libs/thread/test/test_condition_notify_one.cpp
index 5bd5f7e43..23fe74dfc 100644
--- a/libs/thread/test/test_condition_notify_one.cpp
+++ b/libs/thread/test/test_condition_notify_one.cpp
@@ -5,6 +5,8 @@
#define BOOST_THREAD_VERSION 2
+#define BOOST_TEST_MODULE Boost.Threads: condition_variable notify_one test suite
+
#include <boost/thread/detail/config.hpp>
#include <boost/thread/thread_only.hpp>
@@ -135,7 +137,7 @@ void do_test_multiple_notify_one_calls_wakes_multiple_threads()
thread3.join();
}
-void test_condition_notify_one()
+BOOST_AUTO_TEST_CASE(test_condition_notify_one)
{
timed_test(&do_test_condition_notify_one_wakes_from_wait, timeout_seconds, execution_monitor::use_mutex);
timed_test(&do_test_condition_notify_one_wakes_from_wait_with_predicate, timeout_seconds, execution_monitor::use_mutex);
@@ -144,15 +146,3 @@ void test_condition_notify_one()
timed_test(&do_test_condition_notify_one_wakes_from_relative_timed_wait_with_predicate, timeout_seconds, execution_monitor::use_mutex);
timed_test(&do_test_multiple_notify_one_calls_wakes_multiple_threads, timeout_seconds, execution_monitor::use_mutex);
}
-
-
-boost::unit_test::test_suite* init_unit_test_suite(int, char*[])
-{
- boost::unit_test::test_suite* test =
- BOOST_TEST_SUITE("Boost.Threads: condition test suite");
-
- test->add(BOOST_TEST_CASE(&test_condition_notify_one));
-
- return test;
-}
-
diff --git a/libs/thread/test/test_condition_timed_wait_times_out.cpp b/libs/thread/test/test_condition_timed_wait_times_out.cpp
index 3632286ee..8e19cd7bf 100644
--- a/libs/thread/test/test_condition_timed_wait_times_out.cpp
+++ b/libs/thread/test/test_condition_timed_wait_times_out.cpp
@@ -5,6 +5,8 @@
#define BOOST_THREAD_VERSION 2
+#define BOOST_TEST_MODULE Boost.Threads: condition_variable test suite
+
#include <boost/thread/detail/config.hpp>
#include <boost/thread/condition.hpp>
@@ -152,7 +154,7 @@ void do_test_cv_any_timed_wait_relative_times_out()
}
-void test_timed_wait_times_out()
+BOOST_AUTO_TEST_CASE(test_timed_wait_times_out)
{
timed_test(&do_test_timed_wait_times_out, timeout_seconds+timeout_grace, execution_monitor::use_mutex);
timed_test(&do_test_timed_wait_with_predicate_times_out, timeout_seconds+timeout_grace, execution_monitor::use_mutex);
@@ -164,14 +166,4 @@ void test_timed_wait_times_out()
timed_test(&do_test_cv_any_timed_wait_relative_times_out, timeout_seconds+timeout_grace, execution_monitor::use_mutex);
}
-boost::unit_test::test_suite* init_unit_test_suite(int, char*[])
-{
- boost::unit_test::test_suite* test =
- BOOST_TEST_SUITE("Boost.Threads: condition test suite");
-
- test->add(BOOST_TEST_CASE(&test_timed_wait_times_out));
-
- return test;
-}
-
diff --git a/libs/thread/test/test_futures.cpp b/libs/thread/test/test_futures.cpp
index a6aad6361..33698bae9 100644
--- a/libs/thread/test/test_futures.cpp
+++ b/libs/thread/test/test_futures.cpp
@@ -5,6 +5,7 @@
// http://www.boost.org/LICENSE_1_0.txt)
#define BOOST_THREAD_VERSION 2
+#define BOOST_TEST_MODULE Boost.Threads: futures test suite
#include <boost/thread/thread_only.hpp>
#include <boost/thread/mutex.hpp>
@@ -93,7 +94,7 @@ void set_promise_exception_thread(boost::promise<int>* p)
}
-void test_store_value_from_thread()
+BOOST_AUTO_TEST_CASE(test_store_value_from_thread)
{
LOG;
try {
@@ -122,8 +123,7 @@ void test_store_value_from_thread()
}
}
-
-void test_store_exception()
+BOOST_AUTO_TEST_CASE(test_store_exception)
{
LOG;
boost::promise<int> pi3;
@@ -145,7 +145,7 @@ void test_store_exception()
BOOST_CHECK(fi3.get_state()==boost::future_state::ready);
}
-void test_initial_state()
+BOOST_AUTO_TEST_CASE(test_initial_state)
{
LOG;
boost::unique_future<int> fi;
@@ -166,7 +166,7 @@ void test_initial_state()
}
}
-void test_waiting_future()
+BOOST_AUTO_TEST_CASE(test_waiting_future)
{
LOG;
boost::promise<int> pi;
@@ -181,7 +181,7 @@ void test_waiting_future()
BOOST_CHECK(i==0);
}
-void test_cannot_get_future_twice()
+BOOST_AUTO_TEST_CASE(test_cannot_get_future_twice)
{
LOG;
boost::promise<int> pi;
@@ -198,7 +198,7 @@ void test_cannot_get_future_twice()
}
}
-void test_set_value_updates_future_state()
+BOOST_AUTO_TEST_CASE(test_set_value_updates_future_state)
{
LOG;
boost::promise<int> pi;
@@ -213,7 +213,7 @@ void test_set_value_updates_future_state()
BOOST_CHECK(fi.get_state()==boost::future_state::ready);
}
-void test_set_value_can_be_retrieved()
+BOOST_AUTO_TEST_CASE(test_set_value_can_be_retrieved)
{
LOG;
boost::promise<int> pi;
@@ -231,7 +231,7 @@ void test_set_value_can_be_retrieved()
BOOST_CHECK(fi.get_state()==boost::future_state::ready);
}
-void test_set_value_can_be_moved()
+BOOST_AUTO_TEST_CASE(test_set_value_can_be_moved)
{
LOG;
// boost::promise<int> pi;
@@ -249,7 +249,7 @@ void test_set_value_can_be_moved()
// BOOST_CHECK(fi.get_state()==boost::future_state::ready);
}
-void test_future_from_packaged_task_is_waiting()
+BOOST_AUTO_TEST_CASE(test_future_from_packaged_task_is_waiting)
{
LOG;
boost::packaged_task<int> pt(make_int);
@@ -262,7 +262,7 @@ void test_future_from_packaged_task_is_waiting()
BOOST_CHECK(i==0);
}
-void test_invoking_a_packaged_task_populates_future()
+BOOST_AUTO_TEST_CASE(test_invoking_a_packaged_task_populates_future)
{
LOG;
boost::packaged_task<int> pt(make_int);
@@ -279,7 +279,7 @@ void test_invoking_a_packaged_task_populates_future()
BOOST_CHECK(i==42);
}
-void test_invoking_a_packaged_task_twice_throws()
+BOOST_AUTO_TEST_CASE(test_invoking_a_packaged_task_twice_throws)
{
LOG;
boost::packaged_task<int> pt(make_int);
@@ -297,7 +297,7 @@ void test_invoking_a_packaged_task_twice_throws()
}
-void test_cannot_get_future_twice_from_task()
+BOOST_AUTO_TEST_CASE(test_cannot_get_future_twice_from_task)
{
LOG;
boost::packaged_task<int> pt(make_int);
@@ -313,7 +313,7 @@ void test_cannot_get_future_twice_from_task()
}
}
-void test_task_stores_exception_if_function_throws()
+BOOST_AUTO_TEST_CASE(test_task_stores_exception_if_function_throws)
{
LOG;
boost::packaged_task<int> pt(throw_runtime_error);
@@ -341,7 +341,7 @@ void test_task_stores_exception_if_function_throws()
}
-void test_void_promise()
+BOOST_AUTO_TEST_CASE(test_void_promise)
{
LOG;
boost::promise<void> p;
@@ -354,7 +354,7 @@ void test_void_promise()
f.get();
}
-void test_reference_promise()
+BOOST_AUTO_TEST_CASE(test_reference_promise)
{
LOG;
boost::promise<int&> p;
@@ -371,7 +371,7 @@ void test_reference_promise()
void do_nothing()
{}
-void test_task_returning_void()
+BOOST_AUTO_TEST_CASE(test_task_returning_void)
{
LOG;
boost::packaged_task<void> pt(do_nothing);
@@ -392,7 +392,7 @@ int& return_ref()
return global_ref_target;
}
-void test_task_returning_reference()
+BOOST_AUTO_TEST_CASE(test_task_returning_reference)
{
LOG;
boost::packaged_task<int&> pt(return_ref);
@@ -408,7 +408,7 @@ void test_task_returning_reference()
BOOST_CHECK(&i==&global_ref_target);
}
-void test_shared_future()
+BOOST_AUTO_TEST_CASE(test_shared_future)
{
LOG;
boost::packaged_task<int> pt(make_int);
@@ -428,7 +428,7 @@ void test_shared_future()
BOOST_CHECK(i==42);
}
-void test_copies_of_shared_future_become_ready_together()
+BOOST_AUTO_TEST_CASE(test_copies_of_shared_future_become_ready_together)
{
LOG;
boost::packaged_task<int> pt(make_int);
@@ -467,7 +467,7 @@ void test_copies_of_shared_future_become_ready_together()
BOOST_CHECK(i==42);
}
-void test_shared_future_can_be_move_assigned_from_unique_future()
+BOOST_AUTO_TEST_CASE(test_shared_future_can_be_move_assigned_from_unique_future)
{
LOG;
boost::packaged_task<int> pt(make_int);
@@ -483,7 +483,7 @@ void test_shared_future_can_be_move_assigned_from_unique_future()
BOOST_CHECK(sf.get_state()==boost::future_state::waiting);
}
-void test_shared_future_void()
+BOOST_AUTO_TEST_CASE(test_shared_future_void)
{
LOG;
boost::packaged_task<void> pt(do_nothing);
@@ -501,7 +501,7 @@ void test_shared_future_void()
sf.get();
}
-void test_shared_future_ref()
+BOOST_AUTO_TEST_CASE(test_shared_future_ref)
{
LOG;
boost::promise<int&> p;
@@ -515,7 +515,7 @@ void test_shared_future_ref()
BOOST_CHECK(&f.get()==&i);
}
-void test_can_get_a_second_future_from_a_moved_promise()
+BOOST_AUTO_TEST_CASE(test_can_get_a_second_future_from_a_moved_promise)
{
LOG;
boost::promise<int> pi;
@@ -533,7 +533,7 @@ void test_can_get_a_second_future_from_a_moved_promise()
BOOST_CHECK(fi2.get()==42);
}
-void test_can_get_a_second_future_from_a_moved_void_promise()
+BOOST_AUTO_TEST_CASE(test_can_get_a_second_future_from_a_moved_void_promise)
{
LOG;
boost::promise<void> pi;
@@ -549,7 +549,7 @@ void test_can_get_a_second_future_from_a_moved_void_promise()
BOOST_CHECK(fi2.is_ready());
}
-void test_unique_future_for_move_only_udt()
+BOOST_AUTO_TEST_CASE(test_unique_future_for_move_only_udt)
{
LOG;
boost::promise<X> pt;
@@ -560,7 +560,7 @@ void test_unique_future_for_move_only_udt()
BOOST_CHECK(res.i==42);
}
-void test_unique_future_for_string()
+BOOST_AUTO_TEST_CASE(test_unique_future_for_string)
{
LOG;
boost::promise<std::string> pt;
@@ -611,7 +611,7 @@ void do_nothing_callback(boost::promise<int>& /*pi*/)
++callback_called;
}
-void test_wait_callback()
+BOOST_AUTO_TEST_CASE(test_wait_callback)
{
LOG;
callback_called=0;
@@ -626,7 +626,7 @@ void test_wait_callback()
BOOST_CHECK(callback_called==1);
}
-void test_wait_callback_with_timed_wait()
+BOOST_AUTO_TEST_CASE(test_wait_callback_with_timed_wait)
{
LOG;
callback_called=0;
@@ -665,7 +665,7 @@ void wait_callback_for_task(boost::packaged_task<int>& pt)
}
-void test_wait_callback_for_packaged_task()
+BOOST_AUTO_TEST_CASE(test_wait_callback_for_packaged_task)
{
LOG;
callback_called=0;
@@ -680,7 +680,7 @@ void test_wait_callback_for_packaged_task()
BOOST_CHECK(callback_called==1);
}
-void test_packaged_task_can_be_moved()
+BOOST_AUTO_TEST_CASE(test_packaged_task_can_be_moved)
{
LOG;
boost::packaged_task<int> pt(make_int);
@@ -708,7 +708,7 @@ void test_packaged_task_can_be_moved()
BOOST_CHECK(fi.is_ready());
}
-void test_destroying_a_promise_stores_broken_promise()
+BOOST_AUTO_TEST_CASE(test_destroying_a_promise_stores_broken_promise)
{
LOG;
boost::unique_future<int> f;
@@ -728,7 +728,7 @@ void test_destroying_a_promise_stores_broken_promise()
}
}
-void test_destroying_a_packaged_task_stores_broken_promise()
+BOOST_AUTO_TEST_CASE(test_destroying_a_packaged_task_stores_broken_promise)
{
LOG;
boost::unique_future<int> f;
@@ -754,7 +754,7 @@ int make_int_slowly()
return 42;
}
-void test_wait_for_either_of_two_futures_1()
+BOOST_AUTO_TEST_CASE(test_wait_for_either_of_two_futures_1)
{
LOG;
boost::packaged_task<int> pt(make_int_slowly);
@@ -772,7 +772,7 @@ void test_wait_for_either_of_two_futures_1()
BOOST_CHECK(f1.get()==42);
}
-void test_wait_for_either_of_two_futures_2()
+BOOST_AUTO_TEST_CASE(test_wait_for_either_of_two_futures_2)
{
LOG;
boost::packaged_task<int> pt(make_int_slowly);
@@ -790,7 +790,7 @@ void test_wait_for_either_of_two_futures_2()
BOOST_CHECK(f2.get()==42);
}
-void test_wait_for_either_of_three_futures_1()
+BOOST_AUTO_TEST_CASE(test_wait_for_either_of_three_futures_1)
{
LOG;
boost::packaged_task<int> pt(make_int_slowly);
@@ -811,7 +811,7 @@ void test_wait_for_either_of_three_futures_1()
BOOST_CHECK(f1.get()==42);
}
-void test_wait_for_either_of_three_futures_2()
+BOOST_AUTO_TEST_CASE(test_wait_for_either_of_three_futures_2)
{
LOG;
boost::packaged_task<int> pt(make_int_slowly);
@@ -832,7 +832,7 @@ void test_wait_for_either_of_three_futures_2()
BOOST_CHECK(f2.get()==42);
}
-void test_wait_for_either_of_three_futures_3()
+BOOST_AUTO_TEST_CASE(test_wait_for_either_of_three_futures_3)
{
LOG;
boost::packaged_task<int> pt(make_int_slowly);
@@ -853,7 +853,7 @@ void test_wait_for_either_of_three_futures_3()
BOOST_CHECK(f3.get()==42);
}
-void test_wait_for_either_of_four_futures_1()
+BOOST_AUTO_TEST_CASE(test_wait_for_either_of_four_futures_1)
{
LOG;
boost::packaged_task<int> pt(make_int_slowly);
@@ -877,7 +877,7 @@ void test_wait_for_either_of_four_futures_1()
BOOST_CHECK(f1.get()==42);
}
-void test_wait_for_either_of_four_futures_2()
+BOOST_AUTO_TEST_CASE(test_wait_for_either_of_four_futures_2)
{
LOG;
boost::packaged_task<int> pt(make_int_slowly);
@@ -901,7 +901,7 @@ void test_wait_for_either_of_four_futures_2()
BOOST_CHECK(f2.get()==42);
}
-void test_wait_for_either_of_four_futures_3()
+BOOST_AUTO_TEST_CASE(test_wait_for_either_of_four_futures_3)
{
LOG;
boost::packaged_task<int> pt(make_int_slowly);
@@ -925,7 +925,7 @@ void test_wait_for_either_of_four_futures_3()
BOOST_CHECK(f3.get()==42);
}
-void test_wait_for_either_of_four_futures_4()
+BOOST_AUTO_TEST_CASE(test_wait_for_either_of_four_futures_4)
{
LOG;
boost::packaged_task<int> pt(make_int_slowly);
@@ -949,7 +949,7 @@ void test_wait_for_either_of_four_futures_4()
BOOST_CHECK(f4.get()==42);
}
-void test_wait_for_either_of_five_futures_1()
+BOOST_AUTO_TEST_CASE(test_wait_for_either_of_five_futures_1)
{
LOG;
boost::packaged_task<int> pt(make_int_slowly);
@@ -976,7 +976,7 @@ void test_wait_for_either_of_five_futures_1()
BOOST_CHECK(f1.get()==42);
}
-void test_wait_for_either_of_five_futures_2()
+BOOST_AUTO_TEST_CASE(test_wait_for_either_of_five_futures_2)
{
LOG;
boost::packaged_task<int> pt(make_int_slowly);
@@ -1002,7 +1002,7 @@ void test_wait_for_either_of_five_futures_2()
BOOST_CHECK(!f5.is_ready());
BOOST_CHECK(f2.get()==42);
}
-void test_wait_for_either_of_five_futures_3()
+BOOST_AUTO_TEST_CASE(test_wait_for_either_of_five_futures_3)
{
LOG;
boost::packaged_task<int> pt(make_int_slowly);
@@ -1028,7 +1028,7 @@ void test_wait_for_either_of_five_futures_3()
BOOST_CHECK(!f5.is_ready());
BOOST_CHECK(f3.get()==42);
}
-void test_wait_for_either_of_five_futures_4()
+BOOST_AUTO_TEST_CASE(test_wait_for_either_of_five_futures_4)
{
LOG;
boost::packaged_task<int> pt(make_int_slowly);
@@ -1054,7 +1054,7 @@ void test_wait_for_either_of_five_futures_4()
BOOST_CHECK(!f5.is_ready());
BOOST_CHECK(f4.get()==42);
}
-void test_wait_for_either_of_five_futures_5()
+BOOST_AUTO_TEST_CASE(test_wait_for_either_of_five_futures_5)
{
LOG;
boost::packaged_task<int> pt(make_int_slowly);
@@ -1081,7 +1081,7 @@ void test_wait_for_either_of_five_futures_5()
BOOST_CHECK(f5.get()==42);
}
-void test_wait_for_either_invokes_callbacks()
+BOOST_AUTO_TEST_CASE(test_wait_for_either_invokes_callbacks)
{
LOG;
callback_called=0;
@@ -1098,7 +1098,7 @@ void test_wait_for_either_invokes_callbacks()
BOOST_CHECK(fi.get()==42);
}
-void test_wait_for_any_from_range()
+BOOST_AUTO_TEST_CASE(test_wait_for_any_from_range)
{
LOG;
unsigned const count=10;
@@ -1133,7 +1133,7 @@ void test_wait_for_any_from_range()
}
}
-void test_wait_for_all_from_range()
+BOOST_AUTO_TEST_CASE(test_wait_for_all_from_range)
{
LOG;
unsigned const count=10;
@@ -1153,7 +1153,7 @@ void test_wait_for_all_from_range()
}
}
-void test_wait_for_all_two_futures()
+BOOST_AUTO_TEST_CASE(test_wait_for_all_two_futures)
{
LOG;
unsigned const count=2;
@@ -1173,7 +1173,7 @@ void test_wait_for_all_two_futures()
}
}
-void test_wait_for_all_three_futures()
+BOOST_AUTO_TEST_CASE(test_wait_for_all_three_futures)
{
LOG;
unsigned const count=3;
@@ -1193,7 +1193,7 @@ void test_wait_for_all_three_futures()
}
}
-void test_wait_for_all_four_futures()
+BOOST_AUTO_TEST_CASE(test_wait_for_all_four_futures)
{
LOG;
unsigned const count=4;
@@ -1213,7 +1213,7 @@ void test_wait_for_all_four_futures()
}
}
-void test_wait_for_all_five_futures()
+BOOST_AUTO_TEST_CASE(test_wait_for_all_five_futures)
{
LOG;
unsigned const count=5;
@@ -1232,68 +1232,3 @@ void test_wait_for_all_five_futures()
BOOST_CHECK(futures[j].is_ready());
}
}
-
-
-boost::unit_test::test_suite* init_unit_test_suite(int, char*[])
-{
- boost::unit_test::test_suite* test =
- BOOST_TEST_SUITE("Boost.Threads: futures test suite");
-
- test->add(BOOST_TEST_CASE(test_initial_state));
- test->add(BOOST_TEST_CASE(test_waiting_future));
- test->add(BOOST_TEST_CASE(test_cannot_get_future_twice));
- test->add(BOOST_TEST_CASE(test_set_value_updates_future_state));
- test->add(BOOST_TEST_CASE(test_set_value_can_be_retrieved));
- test->add(BOOST_TEST_CASE(test_set_value_can_be_moved));
- test->add(BOOST_TEST_CASE(test_store_value_from_thread));
- test->add(BOOST_TEST_CASE(test_store_exception));
- test->add(BOOST_TEST_CASE(test_future_from_packaged_task_is_waiting));
- test->add(BOOST_TEST_CASE(test_invoking_a_packaged_task_populates_future));
- test->add(BOOST_TEST_CASE(test_invoking_a_packaged_task_twice_throws));
- test->add(BOOST_TEST_CASE(test_cannot_get_future_twice_from_task));
- test->add(BOOST_TEST_CASE(test_task_stores_exception_if_function_throws));
- test->add(BOOST_TEST_CASE(test_void_promise));
- test->add(BOOST_TEST_CASE(test_reference_promise));
- test->add(BOOST_TEST_CASE(test_task_returning_void));
- test->add(BOOST_TEST_CASE(test_task_returning_reference));
- test->add(BOOST_TEST_CASE(test_shared_future));
- test->add(BOOST_TEST_CASE(test_copies_of_shared_future_become_ready_together));
- test->add(BOOST_TEST_CASE(test_shared_future_can_be_move_assigned_from_unique_future));
- test->add(BOOST_TEST_CASE(test_shared_future_void));
- test->add(BOOST_TEST_CASE(test_shared_future_ref));
- test->add(BOOST_TEST_CASE(test_can_get_a_second_future_from_a_moved_promise));
- test->add(BOOST_TEST_CASE(test_can_get_a_second_future_from_a_moved_void_promise));
- test->add(BOOST_TEST_CASE(test_unique_future_for_move_only_udt));
- test->add(BOOST_TEST_CASE(test_unique_future_for_string));
- test->add(BOOST_TEST_CASE(test_wait_callback));
- test->add(BOOST_TEST_CASE(test_wait_callback_with_timed_wait));
- test->add(BOOST_TEST_CASE(test_wait_callback_for_packaged_task));
- test->add(BOOST_TEST_CASE(test_packaged_task_can_be_moved));
- test->add(BOOST_TEST_CASE(test_destroying_a_promise_stores_broken_promise));
- test->add(BOOST_TEST_CASE(test_destroying_a_packaged_task_stores_broken_promise));
- test->add(BOOST_TEST_CASE(test_wait_for_either_of_two_futures_1));
- test->add(BOOST_TEST_CASE(test_wait_for_either_of_two_futures_2));
- test->add(BOOST_TEST_CASE(test_wait_for_either_of_three_futures_1));
- test->add(BOOST_TEST_CASE(test_wait_for_either_of_three_futures_2));
- test->add(BOOST_TEST_CASE(test_wait_for_either_of_three_futures_3));
- test->add(BOOST_TEST_CASE(test_wait_for_either_of_four_futures_1));
- test->add(BOOST_TEST_CASE(test_wait_for_either_of_four_futures_2));
- test->add(BOOST_TEST_CASE(test_wait_for_either_of_four_futures_3));
- test->add(BOOST_TEST_CASE(test_wait_for_either_of_four_futures_4));
- test->add(BOOST_TEST_CASE(test_wait_for_either_of_five_futures_1));
- test->add(BOOST_TEST_CASE(test_wait_for_either_of_five_futures_2));
- test->add(BOOST_TEST_CASE(test_wait_for_either_of_five_futures_3));
- test->add(BOOST_TEST_CASE(test_wait_for_either_of_five_futures_4));
- test->add(BOOST_TEST_CASE(test_wait_for_either_of_five_futures_5));
- test->add(BOOST_TEST_CASE(test_wait_for_either_invokes_callbacks));
- test->add(BOOST_TEST_CASE(test_wait_for_any_from_range));
- test->add(BOOST_TEST_CASE(test_wait_for_all_from_range));
- test->add(BOOST_TEST_CASE(test_wait_for_all_two_futures));
- test->add(BOOST_TEST_CASE(test_wait_for_all_three_futures));
- test->add(BOOST_TEST_CASE(test_wait_for_all_four_futures));
- test->add(BOOST_TEST_CASE(test_wait_for_all_five_futures));
-
- return test;
-}
-
-
diff --git a/libs/thread/test/test_generic_locks.cpp b/libs/thread/test/test_generic_locks.cpp
index f7c560895..22aed6e65 100644
--- a/libs/thread/test/test_generic_locks.cpp
+++ b/libs/thread/test/test_generic_locks.cpp
@@ -5,13 +5,15 @@
#define BOOST_THREAD_VERSION 2
+#define BOOST_TEST_MODULE Boost.Threads: generic locks test suite
+
#include <boost/test/unit_test.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/thread_only.hpp>
#include <boost/thread/locks.hpp>
#include <boost/thread/condition_variable.hpp>
-void test_lock_two_uncontended()
+BOOST_AUTO_TEST_CASE(test_lock_two_uncontended)
{
boost::mutex m1,m2;
@@ -87,7 +89,7 @@ void lock_pair(boost::mutex* m1,boost::mutex* m2)
l2(*m2,boost::adopt_lock);
}
-void test_lock_two_other_thread_locks_in_order()
+BOOST_AUTO_TEST_CASE(test_lock_two_other_thread_locks_in_order)
{
boost::mutex m1,m2;
wait_data locked;
@@ -106,7 +108,7 @@ void test_lock_two_other_thread_locks_in_order()
t.join();
}
-void test_lock_two_other_thread_locks_in_opposite_order()
+BOOST_AUTO_TEST_CASE(test_lock_two_other_thread_locks_in_opposite_order)
{
boost::mutex m1,m2;
wait_data locked;
@@ -125,7 +127,7 @@ void test_lock_two_other_thread_locks_in_opposite_order()
t.join();
}
-void test_lock_five_uncontended()
+BOOST_AUTO_TEST_CASE(test_lock_five_uncontended)
{
boost::mutex m1,m2,m3,m4,m5;
@@ -176,7 +178,7 @@ void lock_five(boost::mutex* m1,boost::mutex* m2,boost::mutex* m3,boost::mutex*
m5->unlock();
}
-void test_lock_five_other_thread_locks_in_order()
+BOOST_AUTO_TEST_CASE(test_lock_five_other_thread_locks_in_order)
{
boost::mutex m1,m2,m3,m4,m5;
wait_data locked;
@@ -195,7 +197,7 @@ void test_lock_five_other_thread_locks_in_order()
t.join();
}
-void test_lock_five_other_thread_locks_in_different_order()
+BOOST_AUTO_TEST_CASE(test_lock_five_other_thread_locks_in_different_order)
{
boost::mutex m1,m2,m3,m4,m5;
wait_data locked;
@@ -224,7 +226,7 @@ void lock_n(boost::mutex* mutexes,unsigned count)
}
-void test_lock_ten_other_thread_locks_in_different_order()
+BOOST_AUTO_TEST_CASE(test_lock_ten_other_thread_locks_in_different_order)
{
unsigned const num_mutexes=10;
@@ -285,7 +287,7 @@ namespace boost
-void test_lock_five_in_range()
+BOOST_AUTO_TEST_CASE(test_lock_five_in_range)
{
unsigned const num_mutexes=5;
dummy_mutex mutexes[num_mutexes];
@@ -350,7 +352,7 @@ public:
};
-void test_lock_five_in_range_custom_iterator()
+BOOST_AUTO_TEST_CASE(test_lock_five_in_range_custom_iterator)
{
unsigned const num_mutexes=5;
dummy_mutex mutexes[num_mutexes];
@@ -368,7 +370,7 @@ class dummy_mutex2:
{};
-void test_lock_ten_in_range_inherited_mutex()
+BOOST_AUTO_TEST_CASE(test_lock_ten_in_range_inherited_mutex)
{
unsigned const num_mutexes=10;
dummy_mutex2 mutexes[num_mutexes];
@@ -381,7 +383,7 @@ void test_lock_ten_in_range_inherited_mutex()
}
}
-void test_try_lock_two_uncontended()
+BOOST_AUTO_TEST_CASE(test_try_lock_two_uncontended)
{
dummy_mutex m1,m2;
@@ -391,7 +393,7 @@ void test_try_lock_two_uncontended()
BOOST_CHECK(m1.is_locked);
BOOST_CHECK(m2.is_locked);
}
-void test_try_lock_two_first_locked()
+BOOST_AUTO_TEST_CASE(test_try_lock_two_first_locked)
{
dummy_mutex m1,m2;
m1.lock();
@@ -407,7 +409,7 @@ void test_try_lock_two_first_locked()
BOOST_CHECK(!l1.owns_lock());
BOOST_CHECK(!l2.owns_lock());
}
-void test_try_lock_two_second_locked()
+BOOST_AUTO_TEST_CASE(test_try_lock_two_second_locked)
{
dummy_mutex m1,m2;
m2.lock();
@@ -424,7 +426,7 @@ void test_try_lock_two_second_locked()
BOOST_CHECK(!l2.owns_lock());
}
-void test_try_lock_three()
+BOOST_AUTO_TEST_CASE(test_try_lock_three)
{
int const num_mutexes=3;
@@ -469,7 +471,7 @@ void test_try_lock_three()
}
}
-void test_try_lock_four()
+BOOST_AUTO_TEST_CASE(test_try_lock_four)
{
int const num_mutexes=4;
@@ -517,7 +519,7 @@ void test_try_lock_four()
}
}
-void test_try_lock_five()
+BOOST_AUTO_TEST_CASE(test_try_lock_five)
{
int const num_mutexes=5;
@@ -568,31 +570,3 @@ void test_try_lock_five()
}
}
-
-
-boost::unit_test::test_suite* init_unit_test_suite(int, char*[])
-{
- boost::unit_test::test_suite* test =
- BOOST_TEST_SUITE("Boost.Threads: generic locks test suite");
-
- test->add(BOOST_TEST_CASE(&test_lock_two_uncontended));
- test->add(BOOST_TEST_CASE(&test_lock_two_other_thread_locks_in_order));
- test->add(BOOST_TEST_CASE(&test_lock_two_other_thread_locks_in_opposite_order));
- test->add(BOOST_TEST_CASE(&test_lock_five_uncontended));
- test->add(BOOST_TEST_CASE(&test_lock_five_other_thread_locks_in_order));
- test->add(BOOST_TEST_CASE(&test_lock_five_other_thread_locks_in_different_order));
- test->add(BOOST_TEST_CASE(&test_lock_five_in_range));
- test->add(BOOST_TEST_CASE(&test_lock_five_in_range_custom_iterator));
- test->add(BOOST_TEST_CASE(&test_lock_ten_in_range_inherited_mutex));
- test->add(BOOST_TEST_CASE(&test_lock_ten_other_thread_locks_in_different_order));
- test->add(BOOST_TEST_CASE(&test_try_lock_two_uncontended));
- test->add(BOOST_TEST_CASE(&test_try_lock_two_first_locked));
- test->add(BOOST_TEST_CASE(&test_try_lock_two_second_locked));
- test->add(BOOST_TEST_CASE(&test_try_lock_three));
- test->add(BOOST_TEST_CASE(&test_try_lock_four));
- test->add(BOOST_TEST_CASE(&test_try_lock_five));
-
- return test;
-}
-
-
diff --git a/libs/thread/test/test_hardware_concurrency.cpp b/libs/thread/test/test_hardware_concurrency.cpp
index 487aa536b..1d4376c27 100644
--- a/libs/thread/test/test_hardware_concurrency.cpp
+++ b/libs/thread/test/test_hardware_concurrency.cpp
@@ -2,22 +2,16 @@
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+#define BOOST_TEST_MODULE Boost.Threads: hardware_concurrency test suite
+
#include <boost/thread/thread_only.hpp>
#include <boost/test/unit_test.hpp>
#include <boost/thread/mutex.hpp>
-void test_hardware_concurrency_is_non_zero()
+BOOST_AUTO_TEST_CASE(test_hardware_concurrency_is_non_zero)
{
BOOST_CHECK(boost::thread::hardware_concurrency()!=0);
}
-boost::unit_test::test_suite* init_unit_test_suite(int, char*[])
-{
- boost::unit_test::test_suite* test =
- BOOST_TEST_SUITE("Boost.Threads: hardware concurrency test suite");
-
- test->add(BOOST_TEST_CASE(test_hardware_concurrency_is_non_zero));
- return test;
-}
-
diff --git a/libs/thread/test/test_lock_concept.cpp b/libs/thread/test/test_lock_concept.cpp
index ac152bf68..78e70120f 100644
--- a/libs/thread/test/test_lock_concept.cpp
+++ b/libs/thread/test/test_lock_concept.cpp
@@ -4,8 +4,10 @@
// http://www.boost.org/LICENSE_1_0.txt)
#define BOOST_THREAD_VERSION 2
+#define BOOST_TEST_MODULE Boost.Threads: lock_concept test suite
#include <boost/test/unit_test.hpp>
+#include <boost/test/test_case_template.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/lock_types.hpp>
@@ -438,22 +440,30 @@ void test_lock_is_scoped_lock_concept_for_mutex()
test_unlocked_after_try_lock_if_other_thread_has_lock<Mutex,Lock>()();
}
+typedef boost::mpl::vector<boost::mutex,boost::try_mutex,boost::timed_mutex,
+ boost::recursive_mutex,boost::recursive_try_mutex,boost::recursive_timed_mutex> mutex_types_with_scoped_lock;
-BOOST_TEST_CASE_TEMPLATE_FUNCTION(test_scoped_lock_concept,Mutex)
+BOOST_AUTO_TEST_CASE_TEMPLATE(test_scoped_lock_concept,Mutex,mutex_types_with_scoped_lock)
{
typedef typename Mutex::scoped_lock Lock;
test_lock_is_scoped_lock_concept_for_mutex<Mutex,Lock>();
}
-BOOST_TEST_CASE_TEMPLATE_FUNCTION(test_unique_lock_is_scoped_lock,Mutex)
+typedef boost::mpl::vector<boost::mutex,boost::try_mutex,boost::timed_mutex,
+ boost::recursive_mutex,boost::recursive_try_mutex,boost::recursive_timed_mutex,boost::shared_mutex> all_mutex_types;
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(test_unique_lock_is_scoped_lock,Mutex,all_mutex_types)
{
typedef boost::unique_lock<Mutex> Lock;
test_lock_is_scoped_lock_concept_for_mutex<Mutex,Lock>();
}
-BOOST_TEST_CASE_TEMPLATE_FUNCTION(test_scoped_try_lock_concept,Mutex)
+typedef boost::mpl::vector<boost::try_mutex,boost::timed_mutex,
+ boost::recursive_try_mutex,boost::recursive_timed_mutex> mutex_types_with_scoped_try_lock;
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(test_scoped_try_lock_concept,Mutex,mutex_types_with_scoped_try_lock)
{
typedef typename Mutex::scoped_try_lock Lock;
@@ -534,7 +544,7 @@ struct dummy_shared_mutex
};
-void test_shared_lock()
+BOOST_AUTO_TEST_CASE(test_shared_lock)
{
typedef boost::shared_mutex Mutex;
typedef boost::shared_lock<Mutex> Lock;
@@ -564,27 +574,27 @@ void test_shared_lock()
BOOST_CHECK(dummy.shared_timed_locked_absolute);
}
-boost::unit_test::test_suite* init_unit_test_suite(int, char*[])
-{
- boost::unit_test::test_suite* test =
- BOOST_TEST_SUITE("Boost.Threads: lock concept test suite");
-
- typedef boost::mpl::vector<boost::mutex,boost::try_mutex,boost::timed_mutex,
- boost::recursive_mutex,boost::recursive_try_mutex,boost::recursive_timed_mutex> mutex_types_with_scoped_lock;
-
- test->add(BOOST_TEST_CASE_TEMPLATE(test_scoped_lock_concept,mutex_types_with_scoped_lock));
-
- typedef boost::mpl::vector<boost::try_mutex,boost::timed_mutex,
- boost::recursive_try_mutex,boost::recursive_timed_mutex> mutex_types_with_scoped_try_lock;
-
- test->add(BOOST_TEST_CASE_TEMPLATE(test_scoped_try_lock_concept,mutex_types_with_scoped_try_lock));
-
- typedef boost::mpl::vector<boost::mutex,boost::try_mutex,boost::timed_mutex,
- boost::recursive_mutex,boost::recursive_try_mutex,boost::recursive_timed_mutex,boost::shared_mutex> all_mutex_types;
-
- test->add(BOOST_TEST_CASE_TEMPLATE(test_unique_lock_is_scoped_lock,all_mutex_types));
- test->add(BOOST_TEST_CASE(&test_shared_lock));
-
- return test;
-}
+//boost::unit_test::test_suite* init_unit_test_suite(int, char*[])
+//{
+// boost::unit_test::test_suite* test =
+// BOOST_TEST_SUITE("Boost.Threads: lock concept test suite");
+//
+// typedef boost::mpl::vector<boost::mutex,boost::try_mutex,boost::timed_mutex,
+// boost::recursive_mutex,boost::recursive_try_mutex,boost::recursive_timed_mutex> mutex_types_with_scoped_lock;
+//
+// test->add(BOOST_TEST_CASE_TEMPLATE(test_scoped_lock_concept,mutex_types_with_scoped_lock));
+//
+// typedef boost::mpl::vector<boost::try_mutex,boost::timed_mutex,
+// boost::recursive_try_mutex,boost::recursive_timed_mutex> mutex_types_with_scoped_try_lock;
+//
+// test->add(BOOST_TEST_CASE_TEMPLATE(test_scoped_try_lock_concept,mutex_types_with_scoped_try_lock));
+//
+// typedef boost::mpl::vector<boost::mutex,boost::try_mutex,boost::timed_mutex,
+// boost::recursive_mutex,boost::recursive_try_mutex,boost::recursive_timed_mutex,boost::shared_mutex> all_mutex_types;
+//
+// test->add(BOOST_TEST_CASE_TEMPLATE(test_unique_lock_is_scoped_lock,all_mutex_types));
+// test->add(BOOST_TEST_CASE(&test_shared_lock));
+//
+// return test;
+//}
diff --git a/libs/thread/test/test_move_function.cpp b/libs/thread/test/test_move_function.cpp
index 6eb145231..1fef7a3bb 100644
--- a/libs/thread/test/test_move_function.cpp
+++ b/libs/thread/test/test_move_function.cpp
@@ -4,6 +4,7 @@
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#define BOOST_THREAD_VERSION 2
+#define BOOST_TEST_MODULE Boost.Threads: move function test suite
#include <boost/thread/thread_only.hpp>
#include <boost/test/unit_test.hpp>
@@ -13,7 +14,7 @@
void do_nothing()
{}
-void test_thread_move_from_lvalue_on_construction()
+BOOST_AUTO_TEST_CASE(test_thread_move_from_lvalue_on_construction)
{
boost::thread src(do_nothing);
boost::thread::id src_id=src.get_id();
@@ -24,7 +25,7 @@ void test_thread_move_from_lvalue_on_construction()
dest.join();
}
-void test_thread_move_from_lvalue_on_assignment()
+BOOST_AUTO_TEST_CASE(test_thread_move_from_lvalue_on_assignment)
{
boost::thread src(do_nothing);
boost::thread::id src_id=src.get_id();
@@ -41,14 +42,14 @@ boost::thread start_thread()
return boost::thread(do_nothing);
}
-void test_thread_move_from_rvalue_on_construction()
+BOOST_AUTO_TEST_CASE(test_thread_move_from_rvalue_on_construction)
{
boost::thread x(start_thread());
BOOST_CHECK(x.get_id()!=boost::thread::id());
x.join();
}
-void test_thread_move_from_rvalue_using_explicit_move()
+BOOST_AUTO_TEST_CASE(test_thread_move_from_rvalue_using_explicit_move)
{
//boost::thread x(boost::move(start_thread()));
boost::thread x=start_thread();
@@ -56,7 +57,7 @@ void test_thread_move_from_rvalue_using_explicit_move()
x.join();
}
-void test_unique_lock_move_from_lvalue_on_construction()
+BOOST_AUTO_TEST_CASE(test_unique_lock_move_from_lvalue_on_construction)
{
boost::mutex m;
boost::unique_lock<boost::mutex> l(m);
@@ -76,7 +77,7 @@ boost::unique_lock<boost::mutex> get_lock(boost::mutex& m)
}
-void test_unique_lock_move_from_rvalue_on_construction()
+BOOST_AUTO_TEST_CASE(test_unique_lock_move_from_rvalue_on_construction)
{
boost::mutex m;
boost::unique_lock<boost::mutex> l(get_lock(m));
@@ -117,7 +118,7 @@ namespace boost
BOOST_THREAD_DCL_MOVABLE(user_test_ns::nc)
}
-void test_move_for_user_defined_type_unaffected()
+BOOST_AUTO_TEST_CASE(test_move_for_user_defined_type_unaffected)
{
user_test_ns::nc src;
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
@@ -128,19 +129,6 @@ void test_move_for_user_defined_type_unaffected()
BOOST_CHECK(user_test_ns::move_called);
}
-boost::unit_test::test_suite* init_unit_test_suite(int, char*[])
-{
- boost::unit_test::test_suite* test =
- BOOST_TEST_SUITE("Boost.Threads: thread move test suite");
-
- test->add(BOOST_TEST_CASE(test_thread_move_from_lvalue_on_construction));
- test->add(BOOST_TEST_CASE(test_thread_move_from_rvalue_on_construction));
- test->add(BOOST_TEST_CASE(test_thread_move_from_rvalue_using_explicit_move));
- test->add(BOOST_TEST_CASE(test_thread_move_from_lvalue_on_assignment));
- test->add(BOOST_TEST_CASE(test_unique_lock_move_from_lvalue_on_construction));
- test->add(BOOST_TEST_CASE(test_unique_lock_move_from_rvalue_on_construction));
- test->add(BOOST_TEST_CASE(test_move_for_user_defined_type_unaffected));
- return test;
-}
+
diff --git a/libs/thread/test/test_mutex.cpp b/libs/thread/test/test_mutex.cpp
index c10125a28..e6ac24e27 100644
--- a/libs/thread/test/test_mutex.cpp
+++ b/libs/thread/test/test_mutex.cpp
@@ -5,6 +5,7 @@
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#define BOOST_THREAD_VERSION 2
+#define BOOST_TEST_MODULE Boost.Threads: mutex test suite
#include <boost/thread/detail/config.hpp>
@@ -15,6 +16,8 @@
#include <boost/thread/thread_time.hpp>
#include <boost/thread/condition.hpp>
+#define BOOST_TEST_MODULE Boost.Threads: mutex test suite
+
#include <boost/test/unit_test.hpp>
#define DEFAULT_EXECUTION_MONITOR_TYPE execution_monitor::use_sleep_only
@@ -270,7 +273,7 @@ void do_test_mutex()
test_lock<boost::mutex>()();
}
-void test_mutex()
+BOOST_AUTO_TEST_CASE(test_mutex)
{
timed_test(&do_test_mutex, 3);
}
@@ -281,7 +284,7 @@ void do_test_try_mutex()
test_trylock<boost::try_mutex>()();
}
-void test_try_mutex()
+BOOST_AUTO_TEST_CASE(test_try_mutex)
{
timed_test(&do_test_try_mutex, 3);
}
@@ -293,7 +296,7 @@ void do_test_timed_mutex()
test_timedlock<boost::timed_mutex>()();
}
-void test_timed_mutex()
+BOOST_AUTO_TEST_CASE(test_timed_mutex)
{
timed_test(&do_test_timed_mutex, 3);
}
@@ -304,7 +307,7 @@ void do_test_recursive_mutex()
test_recursive_lock<boost::recursive_mutex>()();
}
-void test_recursive_mutex()
+BOOST_AUTO_TEST_CASE(test_recursive_mutex)
{
timed_test(&do_test_recursive_mutex, 3);
}
@@ -316,7 +319,7 @@ void do_test_recursive_try_mutex()
test_recursive_lock<boost::recursive_try_mutex>()();
}
-void test_recursive_try_mutex()
+BOOST_AUTO_TEST_CASE(test_recursive_try_mutex)
{
timed_test(&do_test_recursive_try_mutex, 3);
}
@@ -329,24 +332,10 @@ void do_test_recursive_timed_mutex()
test_recursive_lock<boost::recursive_timed_mutex>()();
}
-void test_recursive_timed_mutex()
+BOOST_AUTO_TEST_CASE(test_recursive_timed_mutex)
{
timed_test(&do_test_recursive_timed_mutex, 3);
}
-boost::unit_test::test_suite* init_unit_test_suite(int, char*[])
-{
- boost::unit_test::test_suite* test =
- BOOST_TEST_SUITE("Boost.Threads: mutex test suite");
-
- test->add(BOOST_TEST_CASE(&test_mutex));
- test->add(BOOST_TEST_CASE(&test_try_mutex));
- test->add(BOOST_TEST_CASE(&test_timed_mutex));
- test->add(BOOST_TEST_CASE(&test_recursive_mutex));
- test->add(BOOST_TEST_CASE(&test_recursive_try_mutex));
- test->add(BOOST_TEST_CASE(&test_recursive_timed_mutex));
-
- return test;
-}
diff --git a/libs/thread/test/test_once.cpp b/libs/thread/test/test_once.cpp
index 35eaa1017..0232e59af 100644
--- a/libs/thread/test/test_once.cpp
+++ b/libs/thread/test/test_once.cpp
@@ -5,6 +5,7 @@
#define BOOST_THREAD_VERSION 2
#define BOOST_THREAD_PROVIDES_INTERRUPTIONS
+#define BOOST_TEST_MODULE Boost.Threads: once test suite
#include <boost/test/unit_test.hpp>
#include <boost/thread/thread.hpp>
@@ -43,7 +44,7 @@ void call_once_thread()
BOOST_CHECK_EQUAL(my_once_value, 1);
}
-void test_call_once()
+BOOST_AUTO_TEST_CASE(test_call_once)
{
LOG;
@@ -102,7 +103,7 @@ void call_once_with_functor()
BOOST_CHECK_EQUAL(my_once_value, 1);
}
-void test_call_once_arbitrary_functor()
+BOOST_AUTO_TEST_CASE(test_call_once_arbitrary_functor)
{
LOG;
@@ -163,7 +164,7 @@ void call_once_with_exception()
}
}
-void test_call_once_retried_on_exception()
+BOOST_AUTO_TEST_CASE(test_call_once_retried_on_exception)
{
LOG;
unsigned const num_threads=20;
@@ -189,16 +190,3 @@ void test_call_once_retried_on_exception()
}
-boost::unit_test::test_suite* init_unit_test_suite(int, char*[])
-{
- boost::unit_test::test_suite* test =
- BOOST_TEST_SUITE("Boost.Threads: call_once test suite");
-
- test->add(BOOST_TEST_CASE(test_call_once));
- test->add(BOOST_TEST_CASE(test_call_once_arbitrary_functor));
- test->add(BOOST_TEST_CASE(test_call_once_retried_on_exception));
-
- return test;
-}
-
-
diff --git a/libs/thread/test/test_physical_concurrency.cpp b/libs/thread/test/test_physical_concurrency.cpp
index 20b5dc028..6a8bbc8f7 100644
--- a/libs/thread/test/test_physical_concurrency.cpp
+++ b/libs/thread/test/test_physical_concurrency.cpp
@@ -3,22 +3,18 @@
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+#define BOOST_TEST_MODULE Boost.Threads: physical_concurrency test suite
+
#include <boost/thread/thread_only.hpp>
#include <boost/test/unit_test.hpp>
#include <boost/thread/mutex.hpp>
-void test_physical_concurrency_is_non_zero()
+BOOST_AUTO_TEST_CASE(test_physical_concurrency_is_non_zero)
{
BOOST_CHECK(boost::thread::physical_concurrency()!=0);
}
-boost::unit_test::test_suite* init_unit_test_suite(int, char*[])
-{
- boost::unit_test::test_suite* test =
- BOOST_TEST_SUITE("Boost.Threads: physical concurrency test suite");
- test->add(BOOST_TEST_CASE(test_physical_concurrency_is_non_zero));
- return test;
-}
diff --git a/libs/thread/test/test_scheduled_tp.cpp b/libs/thread/test/test_scheduled_tp.cpp
new file mode 100644
index 000000000..b4503a8bf
--- /dev/null
+++ b/libs/thread/test/test_scheduled_tp.cpp
@@ -0,0 +1,97 @@
+// Copyright (C) 2014 Ian Forbed
+// Copyright (C) 2014 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+
+#include <boost/config.hpp>
+#if ! defined BOOST_NO_CXX11_DECLTYPE
+#define BOOST_RESULT_OF_USE_DECLTYPE
+#endif
+
+#define BOOST_THREAD_VERSION 4
+#define BOOST_THREAD_PROVIDES_EXECUTORS
+
+#include <boost/bind.hpp>
+#include <boost/chrono.hpp>
+#include <boost/chrono/chrono_io.hpp>
+#include <boost/function.hpp>
+#include <boost/thread/executors/scheduled_thread_pool.hpp>
+#include <iostream>
+
+#include <boost/core/lightweight_test.hpp>
+
+using namespace boost::chrono;
+
+typedef boost::scheduled_thread_pool scheduled_tp;
+
+void fn(int x)
+{
+ std::cout << x << std::endl;
+}
+
+void func(steady_clock::time_point pushed, steady_clock::duration dur)
+{
+ BOOST_TEST(pushed + dur < steady_clock::now());
+}
+void func2(scheduled_tp* tp, steady_clock::duration d)
+{
+ boost::function<void()> fn = boost::bind(func,steady_clock::now(),d);
+ tp->submit_after(fn, d);
+}
+
+
+
+void test_timing(const int n)
+{
+ //This function should take n seconds to execute.
+ boost::scheduled_thread_pool se(4);
+
+ for(int i = 1; i <= n; i++)
+ {
+ se.submit_after(boost::bind(fn,i), milliseconds(i*100));
+ }
+ boost::this_thread::sleep_for(boost::chrono::seconds(10));
+ //dtor is called here so all task will have to be executed before we return
+}
+
+void test_deque_timing()
+{
+ boost::scheduled_thread_pool se(4);
+ for(int i = 0; i < 10; i++)
+ {
+ steady_clock::duration d = milliseconds(i*100);
+ boost::function<void()> fn = boost::bind(func,steady_clock::now(),d);
+ se.submit_after(fn,d);
+ }
+}
+
+void test_deque_multi(const int n)
+{
+ scheduled_tp se(4);
+ boost::thread_group tg;
+ for(int i = 0; i < n; i++)
+ {
+ steady_clock::duration d = milliseconds(i*100);
+ //boost::function<void()> fn = boost::bind(func,steady_clock::now(),d);
+ //tg.create_thread(boost::bind(boost::mem_fn(&scheduled_tp::submit_after), &se, fn, d));
+ tg.create_thread(boost::bind(func2, &se, d));
+ }
+ tg.join_all();
+ //dtor is called here so execution will block untill all the closures
+ //have been completed.
+}
+
+int main()
+{
+ steady_clock::time_point start = steady_clock::now();
+ test_timing(5);
+ steady_clock::duration diff = steady_clock::now() - start;
+ BOOST_TEST(diff > milliseconds(500));
+ test_deque_timing();
+ test_deque_multi(4);
+ test_deque_multi(8);
+ test_deque_multi(16);
+ return boost::report_errors();
+}
diff --git a/libs/thread/test/test_scheduler.cpp b/libs/thread/test/test_scheduler.cpp
new file mode 100644
index 000000000..5847ff010
--- /dev/null
+++ b/libs/thread/test/test_scheduler.cpp
@@ -0,0 +1,81 @@
+// Copyright (C) 2014 Ian Forbed
+// Copyright (C) 2014 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+
+#include <boost/config.hpp>
+#if ! defined BOOST_NO_CXX11_DECLTYPE
+#define BOOST_RESULT_OF_USE_DECLTYPE
+#endif
+
+#define BOOST_THREAD_VERSION 4
+#define BOOST_THREAD_PROVIDES_EXECUTORS
+
+#include <boost/thread/executors/scheduler.hpp>
+#include <boost/thread/executors/basic_thread_pool.hpp>
+#include <boost/chrono/chrono_io.hpp>
+#include <iostream>
+
+#include <boost/core/lightweight_test.hpp>
+
+using namespace boost::chrono;
+
+
+typedef boost::executors::basic_thread_pool thread_pool;
+
+void fn(int x)
+{
+ //std::cout << "[" << __LINE__ << "] " << steady_clock::now() << std::endl;
+ std::cout << x << std::endl;
+}
+
+void test_scheduler(const int n, boost::scheduler<>& sch)
+{
+ for(int i = 1; i <= n; i++)
+ {
+ sch.submit_after(boost::bind(fn,i), seconds(i));
+ sch.submit_after(boost::bind(fn,i), milliseconds(i*100));
+ }
+}
+
+void test_after(const int n, boost::scheduler<>& sch)
+{
+ for(int i = 1; i <= n; i++)
+ {
+ sch.after(seconds(i)).submit(boost::bind(fn,i));
+ sch.after(milliseconds(i*100)).submit(boost::bind(fn,i));
+ }
+}
+
+void test_at(const int n, boost::scheduler<>& sch)
+{
+ for(int i = 1; i <= n; i++)
+ {
+ sch.at(steady_clock::now()+seconds(i)).submit(boost::bind(fn,i));
+ sch.at(steady_clock::now()+milliseconds(i*100)).submit(boost::bind(fn,i));
+ }
+}
+
+void test_on(const int n, boost::scheduler<>& sch, thread_pool& tp)
+{
+ for(int i = 1; i <= n; i++)
+ {
+ sch.on(tp).after(seconds(i)).submit(boost::bind(fn,i));
+ sch.on(tp).after(milliseconds(i*100)).submit(boost::bind(fn,i));
+ }
+}
+
+int main()
+{
+ thread_pool tp(4);
+ boost::scheduler<> sch;
+ test_scheduler(5, sch);
+ test_after(5, sch);
+ test_at(5, sch);
+ test_on(5, sch, tp);
+ boost::this_thread::sleep_for(boost::chrono::seconds(10));
+
+ return boost::report_errors();
+}
diff --git a/libs/thread/test/test_scheduling_adaptor.cpp b/libs/thread/test/test_scheduling_adaptor.cpp
new file mode 100644
index 000000000..ba43551fe
--- /dev/null
+++ b/libs/thread/test/test_scheduling_adaptor.cpp
@@ -0,0 +1,54 @@
+// Copyright (C) 2014 Ian Forbed
+// Copyright (C) 2014 Vicente J. Botet Escriba
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+
+#include <boost/config.hpp>
+#if ! defined BOOST_NO_CXX11_DECLTYPE
+#define BOOST_RESULT_OF_USE_DECLTYPE
+#endif
+
+#define BOOST_THREAD_VERSION 4
+#define BOOST_THREAD_PROVIDES_EXECUTORS
+
+#include <boost/function.hpp>
+#include <boost/thread/executors/executor.hpp>
+#include <boost/thread/executors/basic_thread_pool.hpp>
+#include <boost/thread/executors/scheduling_adaptor.hpp>
+#include <boost/chrono/chrono_io.hpp>
+
+#include <boost/core/lightweight_test.hpp>
+
+using namespace boost::chrono;
+
+
+typedef boost::executors::basic_thread_pool thread_pool;
+
+void fn(int x)
+{
+ //std::cout << "[" << __LINE__ << "] " << steady_clock::now() << std::endl;
+ std::cout << x << std::endl;
+}
+
+void test_timing(const int n)
+{
+ thread_pool tp(4);
+ boost::scheduling_adpator<thread_pool> sa(tp);
+ for(int i = 1; i <= n; i++)
+ {
+ sa.submit_after(boost::bind(fn,i),seconds(i));
+ sa.submit_after(boost::bind(fn,i), milliseconds(i*100));
+ }
+ boost::this_thread::sleep_for(boost::chrono::seconds(10));
+}
+
+int main()
+{
+ steady_clock::time_point start = steady_clock::now();
+ test_timing(5);
+ steady_clock::duration diff = steady_clock::now() - start;
+ BOOST_TEST(diff > seconds(5));
+ return boost::report_errors();
+}
diff --git a/libs/thread/test/test_shared_mutex.cpp b/libs/thread/test/test_shared_mutex.cpp
index ca10e3000..f7779e90a 100644
--- a/libs/thread/test/test_shared_mutex.cpp
+++ b/libs/thread/test/test_shared_mutex.cpp
@@ -5,6 +5,7 @@
#define BOOST_THREAD_VERSION 2
#define BOOST_THREAD_PROVIDES_INTERRUPTIONS
+#define BOOST_TEST_MODULE Boost.Threads: shared_mutex test suite
#include <boost/test/unit_test.hpp>
#include <boost/thread/thread.hpp>
@@ -18,7 +19,7 @@
BOOST_CHECK_EQUAL(value,expected_value); \
}
-void test_multiple_readers()
+BOOST_AUTO_TEST_CASE(test_multiple_readers)
{
std::cout << __LINE__ << std::endl;
unsigned const number_of_threads=10;
@@ -66,7 +67,7 @@ void test_multiple_readers()
CHECK_LOCKED_VALUE_EQUAL(unblocked_count_mutex,max_simultaneous_running,number_of_threads);
}
-void test_only_one_writer_permitted()
+BOOST_AUTO_TEST_CASE(test_only_one_writer_permitted)
{
std::cout << __LINE__ << std::endl;
unsigned const number_of_threads=10;
@@ -109,7 +110,7 @@ void test_only_one_writer_permitted()
CHECK_LOCKED_VALUE_EQUAL(unblocked_count_mutex,max_simultaneous_running,1u);
}
-void test_reader_blocks_writer()
+BOOST_AUTO_TEST_CASE(test_reader_blocks_writer)
{
std::cout << __LINE__ << std::endl;
boost::thread_group pool;
@@ -156,7 +157,7 @@ void test_reader_blocks_writer()
CHECK_LOCKED_VALUE_EQUAL(unblocked_count_mutex,max_simultaneous_running,1u);
}
-void test_unlocking_writer_unblocks_all_readers()
+BOOST_AUTO_TEST_CASE(test_unlocking_writer_unblocks_all_readers)
{
std::cout << __LINE__ << std::endl;
boost::thread_group pool;
@@ -208,7 +209,7 @@ void test_unlocking_writer_unblocks_all_readers()
CHECK_LOCKED_VALUE_EQUAL(unblocked_count_mutex,max_simultaneous_running,reader_count);
}
-void test_unlocking_last_reader_only_unblocks_one_writer()
+BOOST_AUTO_TEST_CASE(test_unlocking_last_reader_only_unblocks_one_writer)
{
std::cout << __LINE__ << std::endl;
boost::thread_group pool;
@@ -277,19 +278,3 @@ void test_unlocking_last_reader_only_unblocks_one_writer()
CHECK_LOCKED_VALUE_EQUAL(unblocked_count_mutex,max_simultaneous_readers,reader_count);
CHECK_LOCKED_VALUE_EQUAL(unblocked_count_mutex,max_simultaneous_writers,1u);
}
-
-boost::unit_test::test_suite* init_unit_test_suite(int, char*[])
-{
- boost::unit_test::test_suite* test =
- BOOST_TEST_SUITE("Boost.Threads: shared_mutex test suite");
-
- test->add(BOOST_TEST_CASE(&test_multiple_readers));
- test->add(BOOST_TEST_CASE(&test_only_one_writer_permitted));
- test->add(BOOST_TEST_CASE(&test_reader_blocks_writer));
- test->add(BOOST_TEST_CASE(&test_unlocking_writer_unblocks_all_readers));
- test->add(BOOST_TEST_CASE(&test_unlocking_last_reader_only_unblocks_one_writer));
-
- return test;
-}
-
-
diff --git a/libs/thread/test/test_shared_mutex_part_2.cpp b/libs/thread/test/test_shared_mutex_part_2.cpp
index 3f213b6b7..a0b5282c7 100644
--- a/libs/thread/test/test_shared_mutex_part_2.cpp
+++ b/libs/thread/test/test_shared_mutex_part_2.cpp
@@ -4,6 +4,7 @@
// http://www.boost.org/LICENSE_1_0.txt)
#define BOOST_THREAD_VERSION 2
+#define BOOST_TEST_MODULE Boost.Threads: shared_mutex_part2 test suite
#include <boost/test/unit_test.hpp>
#include <boost/thread/thread.hpp>
@@ -49,7 +50,7 @@ public:
};
-void test_only_one_upgrade_lock_permitted()
+BOOST_AUTO_TEST_CASE(test_only_one_upgrade_lock_permitted)
{
unsigned const number_of_threads=2;
@@ -91,7 +92,7 @@ void test_only_one_upgrade_lock_permitted()
CHECK_LOCKED_VALUE_EQUAL(unblocked_count_mutex,max_simultaneous_running,1u);
}
-void test_can_lock_upgrade_if_currently_locked_shared()
+BOOST_AUTO_TEST_CASE(test_can_lock_upgrade_if_currently_locked_shared)
{
boost::thread_group pool;
@@ -140,7 +141,7 @@ void test_can_lock_upgrade_if_currently_locked_shared()
CHECK_LOCKED_VALUE_EQUAL(unblocked_count_mutex,max_simultaneous_running,reader_count+1);
}
-void test_can_lock_upgrade_to_unique_if_currently_locked_upgrade()
+BOOST_AUTO_TEST_CASE(test_can_lock_upgrade_to_unique_if_currently_locked_upgrade)
{
boost::shared_mutex mtx;
boost::upgrade_lock<boost::shared_mutex> l(mtx);
@@ -148,7 +149,7 @@ void test_can_lock_upgrade_to_unique_if_currently_locked_upgrade()
BOOST_CHECK(ul.owns_lock());
}
-void test_if_other_thread_has_write_lock_try_lock_shared_returns_false()
+BOOST_AUTO_TEST_CASE(test_if_other_thread_has_write_lock_try_lock_shared_returns_false)
{
boost::shared_mutex rw_mutex;
@@ -171,7 +172,7 @@ void test_if_other_thread_has_write_lock_try_lock_shared_returns_false()
writer.join();
}
-void test_if_other_thread_has_write_lock_try_lock_upgrade_returns_false()
+BOOST_AUTO_TEST_CASE(test_if_other_thread_has_write_lock_try_lock_upgrade_returns_false)
{
boost::shared_mutex rw_mutex;
@@ -194,7 +195,7 @@ void test_if_other_thread_has_write_lock_try_lock_upgrade_returns_false()
writer.join();
}
-void test_if_no_thread_has_lock_try_lock_shared_returns_true()
+BOOST_AUTO_TEST_CASE(test_if_no_thread_has_lock_try_lock_shared_returns_true)
{
boost::shared_mutex rw_mutex;
bool const try_succeeded=rw_mutex.try_lock_shared();
@@ -205,7 +206,7 @@ void test_if_no_thread_has_lock_try_lock_shared_returns_true()
}
}
-void test_if_no_thread_has_lock_try_lock_upgrade_returns_true()
+BOOST_AUTO_TEST_CASE(test_if_no_thread_has_lock_try_lock_upgrade_returns_true)
{
boost::shared_mutex rw_mutex;
bool const try_succeeded=rw_mutex.try_lock_upgrade();
@@ -216,7 +217,7 @@ void test_if_no_thread_has_lock_try_lock_upgrade_returns_true()
}
}
-void test_if_other_thread_has_shared_lock_try_lock_shared_returns_true()
+BOOST_AUTO_TEST_CASE(test_if_other_thread_has_shared_lock_try_lock_shared_returns_true)
{
boost::shared_mutex rw_mutex;
@@ -239,7 +240,7 @@ void test_if_other_thread_has_shared_lock_try_lock_shared_returns_true()
writer.join();
}
-void test_if_other_thread_has_shared_lock_try_lock_upgrade_returns_true()
+BOOST_AUTO_TEST_CASE(test_if_other_thread_has_shared_lock_try_lock_upgrade_returns_true)
{
boost::shared_mutex rw_mutex;
@@ -262,7 +263,7 @@ void test_if_other_thread_has_shared_lock_try_lock_upgrade_returns_true()
writer.join();
}
-void test_if_other_thread_has_upgrade_lock_try_lock_upgrade_returns_false()
+BOOST_AUTO_TEST_CASE(test_if_other_thread_has_upgrade_lock_try_lock_upgrade_returns_false)
{
boost::shared_mutex rw_mutex;
@@ -285,18 +286,4 @@ void test_if_other_thread_has_upgrade_lock_try_lock_upgrade_returns_false()
writer.join();
}
-boost::unit_test::test_suite* init_unit_test_suite(int, char*[])
-{
- boost::unit_test::test_suite* test =
- BOOST_TEST_SUITE("Boost.Threads: shared_mutex test suite");
-
- test->add(BOOST_TEST_CASE(&test_only_one_upgrade_lock_permitted));
- test->add(BOOST_TEST_CASE(&test_can_lock_upgrade_if_currently_locked_shared));
- test->add(BOOST_TEST_CASE(&test_can_lock_upgrade_to_unique_if_currently_locked_upgrade));
- test->add(BOOST_TEST_CASE(&test_if_other_thread_has_write_lock_try_lock_shared_returns_false));
- test->add(BOOST_TEST_CASE(&test_if_no_thread_has_lock_try_lock_shared_returns_true));
- test->add(BOOST_TEST_CASE(&test_if_other_thread_has_shared_lock_try_lock_shared_returns_true));
-
- return test;
-}
diff --git a/libs/thread/test/test_shared_mutex_timed_locks.cpp b/libs/thread/test/test_shared_mutex_timed_locks.cpp
index 5eea1a1ac..c29c4260c 100644
--- a/libs/thread/test/test_shared_mutex_timed_locks.cpp
+++ b/libs/thread/test/test_shared_mutex_timed_locks.cpp
@@ -4,6 +4,7 @@
// http://www.boost.org/LICENSE_1_0.txt)
#define BOOST_THREAD_VERSION 2
+#define BOOST_TEST_MODULE Boost.Threads: shared_mutex_timed_locks test suite
#include <boost/test/unit_test.hpp>
#include <boost/thread/thread_only.hpp>
@@ -18,7 +19,7 @@
}
-void test_timed_lock_shared_times_out_if_write_lock_held()
+BOOST_AUTO_TEST_CASE(test_timed_lock_shared_times_out_if_write_lock_held)
{
boost::shared_mutex rw_mutex;
boost::mutex finish_mutex;
@@ -54,7 +55,7 @@ void test_timed_lock_shared_times_out_if_write_lock_held()
writer.join();
}
-void test_timed_lock_shared_succeeds_if_no_lock_held()
+BOOST_AUTO_TEST_CASE(test_timed_lock_shared_succeeds_if_no_lock_held)
{
boost::shared_mutex rw_mutex;
boost::mutex finish_mutex;
@@ -83,7 +84,7 @@ void test_timed_lock_shared_succeeds_if_no_lock_held()
}
-void test_timed_lock_shared_succeeds_if_read_lock_held()
+BOOST_AUTO_TEST_CASE(test_timed_lock_shared_succeeds_if_read_lock_held)
{
boost::shared_mutex rw_mutex;
boost::mutex finish_mutex;
@@ -119,7 +120,7 @@ void test_timed_lock_shared_succeeds_if_read_lock_held()
reader.join();
}
-void test_timed_lock_times_out_if_write_lock_held()
+BOOST_AUTO_TEST_CASE(test_timed_lock_times_out_if_write_lock_held)
{
boost::shared_mutex rw_mutex;
boost::mutex finish_mutex;
@@ -155,7 +156,7 @@ void test_timed_lock_times_out_if_write_lock_held()
writer.join();
}
-void test_timed_lock_succeeds_if_no_lock_held()
+BOOST_AUTO_TEST_CASE(test_timed_lock_succeeds_if_no_lock_held)
{
boost::shared_mutex rw_mutex;
boost::mutex finish_mutex;
@@ -184,7 +185,7 @@ void test_timed_lock_succeeds_if_no_lock_held()
}
-void test_timed_lock_times_out_if_read_lock_held()
+BOOST_AUTO_TEST_CASE(test_timed_lock_times_out_if_read_lock_held)
{
boost::shared_mutex rw_mutex;
boost::mutex finish_mutex;
@@ -220,7 +221,7 @@ void test_timed_lock_times_out_if_read_lock_held()
reader.join();
}
-void test_timed_lock_times_out_but_read_lock_succeeds_if_read_lock_held()
+BOOST_AUTO_TEST_CASE(test_timed_lock_times_out_but_read_lock_succeeds_if_read_lock_held)
{
boost::shared_mutex rw_mutex;
boost::mutex finish_mutex;
@@ -252,21 +253,3 @@ void test_timed_lock_times_out_but_read_lock_succeeds_if_read_lock_held()
reader.join();
}
-
-boost::unit_test::test_suite* init_unit_test_suite(int, char*[])
-{
- boost::unit_test::test_suite* test =
- BOOST_TEST_SUITE("Boost.Threads: shared_mutex test suite");
-
- test->add(BOOST_TEST_CASE(&test_timed_lock_shared_times_out_if_write_lock_held));
- test->add(BOOST_TEST_CASE(&test_timed_lock_shared_succeeds_if_no_lock_held));
- test->add(BOOST_TEST_CASE(&test_timed_lock_shared_succeeds_if_read_lock_held));
- test->add(BOOST_TEST_CASE(&test_timed_lock_times_out_if_write_lock_held));
- test->add(BOOST_TEST_CASE(&test_timed_lock_times_out_if_read_lock_held));
- test->add(BOOST_TEST_CASE(&test_timed_lock_succeeds_if_no_lock_held));
- test->add(BOOST_TEST_CASE(&test_timed_lock_times_out_but_read_lock_succeeds_if_read_lock_held));
-
- return test;
-}
-
-
diff --git a/libs/thread/test/test_shared_mutex_timed_locks_chrono.cpp b/libs/thread/test/test_shared_mutex_timed_locks_chrono.cpp
index fd6690c72..95dad0825 100644
--- a/libs/thread/test/test_shared_mutex_timed_locks_chrono.cpp
+++ b/libs/thread/test/test_shared_mutex_timed_locks_chrono.cpp
@@ -4,6 +4,7 @@
// http://www.boost.org/LICENSE_1_0.txt)
#define BOOST_THREAD_VERSION 2
+#define BOOST_TEST_MODULE Boost.Threads: shared_mutex_locks_chrono test suite
#include <boost/test/unit_test.hpp>
#include <boost/thread/thread.hpp>
@@ -20,7 +21,7 @@
}
-void test_timed_lock_shared_times_out_if_write_lock_held()
+BOOST_AUTO_TEST_CASE(test_timed_lock_shared_times_out_if_write_lock_held)
{
boost::shared_mutex rw_mutex;
boost::mutex finish_mutex;
@@ -56,7 +57,7 @@ void test_timed_lock_shared_times_out_if_write_lock_held()
writer.join();
}
-void test_timed_lock_shared_succeeds_if_no_lock_held()
+BOOST_AUTO_TEST_CASE(test_timed_lock_shared_succeeds_if_no_lock_held)
{
boost::shared_mutex rw_mutex;
boost::mutex finish_mutex;
@@ -85,7 +86,7 @@ void test_timed_lock_shared_succeeds_if_no_lock_held()
}
-void test_timed_lock_shared_succeeds_if_read_lock_held()
+BOOST_AUTO_TEST_CASE(test_timed_lock_shared_succeeds_if_read_lock_held)
{
boost::shared_mutex rw_mutex;
boost::mutex finish_mutex;
@@ -121,7 +122,7 @@ void test_timed_lock_shared_succeeds_if_read_lock_held()
reader.join();
}
-void test_timed_lock_times_out_if_write_lock_held()
+BOOST_AUTO_TEST_CASE(test_timed_lock_times_out_if_write_lock_held)
{
boost::shared_mutex rw_mutex;
boost::mutex finish_mutex;
@@ -157,7 +158,7 @@ void test_timed_lock_times_out_if_write_lock_held()
writer.join();
}
-void test_timed_lock_succeeds_if_no_lock_held()
+BOOST_AUTO_TEST_CASE(test_timed_lock_succeeds_if_no_lock_held)
{
boost::shared_mutex rw_mutex;
boost::mutex finish_mutex;
@@ -186,7 +187,7 @@ void test_timed_lock_succeeds_if_no_lock_held()
}
-void test_timed_lock_times_out_if_read_lock_held()
+BOOST_AUTO_TEST_CASE(test_timed_lock_times_out_if_read_lock_held)
{
boost::shared_mutex rw_mutex;
boost::mutex finish_mutex;
@@ -222,7 +223,7 @@ void test_timed_lock_times_out_if_read_lock_held()
reader.join();
}
-void test_timed_lock_times_out_but_read_lock_succeeds_if_read_lock_held()
+BOOST_AUTO_TEST_CASE(test_timed_lock_times_out_but_read_lock_succeeds_if_read_lock_held)
{
boost::shared_mutex rw_mutex;
boost::mutex finish_mutex;
@@ -254,23 +255,6 @@ void test_timed_lock_times_out_but_read_lock_succeeds_if_read_lock_held()
reader.join();
}
-
-boost::unit_test::test_suite* init_unit_test_suite(int, char*[])
-{
- boost::unit_test::test_suite* test =
- BOOST_TEST_SUITE("Boost.Threads: shared_mutex test suite");
-
- test->add(BOOST_TEST_CASE(&test_timed_lock_shared_times_out_if_write_lock_held));
- test->add(BOOST_TEST_CASE(&test_timed_lock_shared_succeeds_if_no_lock_held));
- test->add(BOOST_TEST_CASE(&test_timed_lock_shared_succeeds_if_read_lock_held));
- test->add(BOOST_TEST_CASE(&test_timed_lock_times_out_if_write_lock_held));
- test->add(BOOST_TEST_CASE(&test_timed_lock_times_out_if_read_lock_held));
- test->add(BOOST_TEST_CASE(&test_timed_lock_succeeds_if_no_lock_held));
- test->add(BOOST_TEST_CASE(&test_timed_lock_times_out_but_read_lock_succeeds_if_read_lock_held));
-
- return test;
-}
-
#else
#error "Test not applicable: BOOST_THREAD_USES_CHRONO not defined for this platform as not supported"
#endif
diff --git a/libs/thread/test/test_thread.cpp b/libs/thread/test/test_thread.cpp
index f6a2cb7ae..fa9e556af 100644
--- a/libs/thread/test/test_thread.cpp
+++ b/libs/thread/test/test_thread.cpp
@@ -16,6 +16,8 @@
#include <boost/ref.hpp>
#include <boost/utility.hpp>
+#define BOOST_TEST_MODULE Boost.Threads: thread test suite
+
#include <boost/test/unit_test.hpp>
#define DEFAULT_EXECUTION_MONITOR_TYPE execution_monitor::use_sleep_only
@@ -40,7 +42,7 @@ void comparison_thread(boost::thread::id parent)
BOOST_CHECK(my_id != no_thread_id);
}
-void test_sleep()
+BOOST_AUTO_TEST_CASE(test_sleep)
{
boost::xtime xt = delay(3);
boost::thread::sleep(xt);
@@ -58,7 +60,7 @@ void do_test_creation()
BOOST_CHECK_EQUAL(test_value, 999);
}
-void test_creation()
+BOOST_AUTO_TEST_CASE(test_creation)
{
timed_test(&do_test_creation, 1);
}
@@ -70,7 +72,7 @@ void do_test_id_comparison()
thrd.join();
}
-void test_id_comparison()
+BOOST_AUTO_TEST_CASE(test_id_comparison)
{
timed_test(&do_test_id_comparison, 1);
}
@@ -94,7 +96,7 @@ void do_test_thread_interrupts_at_interruption_point()
BOOST_CHECK(!failed);
}
-void test_thread_interrupts_at_interruption_point()
+BOOST_AUTO_TEST_CASE(test_thread_interrupts_at_interruption_point)
{
timed_test(&do_test_thread_interrupts_at_interruption_point, 1);
}
@@ -119,7 +121,7 @@ void do_test_thread_no_interrupt_if_interrupts_disabled_at_interruption_point()
BOOST_CHECK(!failed);
}
-void test_thread_no_interrupt_if_interrupts_disabled_at_interruption_point()
+BOOST_AUTO_TEST_CASE(test_thread_no_interrupt_if_interrupts_disabled_at_interruption_point)
{
timed_test(&do_test_thread_no_interrupt_if_interrupts_disabled_at_interruption_point, 1);
}
@@ -148,7 +150,7 @@ void do_test_creation_through_reference_wrapper()
BOOST_CHECK_EQUAL(f.value, 999u);
}
-void test_creation_through_reference_wrapper()
+BOOST_AUTO_TEST_CASE(test_creation_through_reference_wrapper)
{
timed_test(&do_test_creation_through_reference_wrapper, 1);
}
@@ -197,12 +199,12 @@ void do_test_timed_join()
BOOST_CHECK(!thrd.joinable());
}
-void test_timed_join()
+BOOST_AUTO_TEST_CASE(test_timed_join)
{
timed_test(&do_test_timed_join, 10);
}
-void test_swap()
+BOOST_AUTO_TEST_CASE(test_swap)
{
boost::thread t(simple_thread);
boost::thread t2(simple_thread);
@@ -218,21 +220,3 @@ void test_swap()
BOOST_CHECK(t2.get_id()==id2);
}
-
-boost::unit_test::test_suite* init_unit_test_suite(int, char*[])
-{
- boost::unit_test::test_suite* test =
- BOOST_TEST_SUITE("Boost.Threads: thread test suite");
-
- test->add(BOOST_TEST_CASE(test_sleep));
- test->add(BOOST_TEST_CASE(test_creation));
- test->add(BOOST_TEST_CASE(test_id_comparison));
- test->add(BOOST_TEST_CASE(test_thread_interrupts_at_interruption_point));
- test->add(BOOST_TEST_CASE(test_thread_no_interrupt_if_interrupts_disabled_at_interruption_point));
- test->add(BOOST_TEST_CASE(test_creation_through_reference_wrapper));
- test->add(BOOST_TEST_CASE(test_timed_join));
- test->add(BOOST_TEST_CASE(test_swap));
-
- return test;
-}
-
diff --git a/libs/thread/test/test_thread_exit.cpp b/libs/thread/test/test_thread_exit.cpp
index abd18a85b..539a50acd 100644
--- a/libs/thread/test/test_thread_exit.cpp
+++ b/libs/thread/test/test_thread_exit.cpp
@@ -12,6 +12,8 @@
#include <memory>
#include <string>
+#define BOOST_TEST_MODULE Boost.Threads: thread exit test suite
+
#include <boost/test/unit_test.hpp>
boost::thread::id exit_func_thread_id;
@@ -27,7 +29,7 @@ void tf1()
BOOST_CHECK(exit_func_thread_id!=boost::this_thread::get_id());
}
-void test_thread_exit_func_runs_when_thread_exits()
+BOOST_AUTO_TEST_CASE(test_thread_exit_func_runs_when_thread_exits)
{
exit_func_thread_id=boost::thread::id();
boost::thread t(tf1);
@@ -51,7 +53,7 @@ void tf2()
}
-void test_can_use_function_object_for_exit_func()
+BOOST_AUTO_TEST_CASE(test_can_use_function_object_for_exit_func)
{
exit_func_thread_id=boost::thread::id();
boost::thread t(tf2);
@@ -59,17 +61,3 @@ void test_can_use_function_object_for_exit_func()
t.join();
BOOST_CHECK(exit_func_thread_id==t_id);
}
-
-
-boost::unit_test::test_suite* init_unit_test_suite(int, char*[])
-{
- boost::unit_test::test_suite* test =
- BOOST_TEST_SUITE("Boost.Threads: futures test suite");
-
- test->add(BOOST_TEST_CASE(test_thread_exit_func_runs_when_thread_exits));
- test->add(BOOST_TEST_CASE(test_can_use_function_object_for_exit_func));
-
- return test;
-}
-
-
diff --git a/libs/thread/test/test_thread_id.cpp b/libs/thread/test/test_thread_id.cpp
index 0a9725ec0..96b98016a 100644
--- a/libs/thread/test/test_thread_id.cpp
+++ b/libs/thread/test/test_thread_id.cpp
@@ -2,6 +2,9 @@
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+#define BOOST_TEST_MODULE Boost.Threads: thread::get_id test suite
+
#include <boost/thread/thread_only.hpp>
#include <boost/test/unit_test.hpp>
#include <boost/bind.hpp>
@@ -9,20 +12,20 @@
void do_nothing()
{}
-void test_thread_id_for_default_constructed_thread_is_default_constructed_id()
+BOOST_AUTO_TEST_CASE(test_thread_id_for_default_constructed_thread_is_default_constructed_id)
{
boost::thread t;
BOOST_CHECK(t.get_id()==boost::thread::id());
}
-void test_thread_id_for_running_thread_is_not_default_constructed_id()
+BOOST_AUTO_TEST_CASE(test_thread_id_for_running_thread_is_not_default_constructed_id)
{
boost::thread t(do_nothing);
BOOST_CHECK(t.get_id()!=boost::thread::id());
t.join();
}
-void test_different_threads_have_different_ids()
+BOOST_AUTO_TEST_CASE(test_different_threads_have_different_ids)
{
boost::thread t(do_nothing);
boost::thread t2(do_nothing);
@@ -31,7 +34,7 @@ void test_different_threads_have_different_ids()
t2.join();
}
-void test_thread_ids_have_a_total_order()
+BOOST_AUTO_TEST_CASE(test_thread_ids_have_a_total_order)
{
boost::thread t(do_nothing);
boost::thread t2(do_nothing);
@@ -126,7 +129,7 @@ void get_thread_id(boost::thread::id* id)
*id=boost::this_thread::get_id();
}
-void test_thread_id_of_running_thread_returned_by_this_thread_get_id()
+BOOST_AUTO_TEST_CASE(test_thread_id_of_running_thread_returned_by_this_thread_get_id)
{
boost::thread::id id;
boost::thread t(boost::bind(get_thread_id,&id));
@@ -134,18 +137,3 @@ void test_thread_id_of_running_thread_returned_by_this_thread_get_id()
t.join();
BOOST_CHECK(id==t_id);
}
-
-boost::unit_test::test_suite* init_unit_test_suite(int, char*[])
-{
- boost::unit_test::test_suite* test =
- BOOST_TEST_SUITE("Boost.Threads: thread move test suite");
-
- test->add(BOOST_TEST_CASE(test_thread_id_for_default_constructed_thread_is_default_constructed_id));
- test->add(BOOST_TEST_CASE(test_thread_id_for_running_thread_is_not_default_constructed_id));
- test->add(BOOST_TEST_CASE(test_different_threads_have_different_ids));
- test->add(BOOST_TEST_CASE(test_thread_ids_have_a_total_order));
- test->add(BOOST_TEST_CASE(test_thread_id_of_running_thread_returned_by_this_thread_get_id));
- return test;
-}
-
-
diff --git a/libs/thread/test/test_thread_launching.cpp b/libs/thread/test/test_thread_launching.cpp
index 656a46ebf..7c0d3f9f0 100644
--- a/libs/thread/test/test_thread_launching.cpp
+++ b/libs/thread/test/test_thread_launching.cpp
@@ -4,6 +4,7 @@
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#define BOOST_THREAD_VERSION 3
+#define BOOST_TEST_MODULE Boost.Threads: thread launching test suite
#include <boost/thread/thread_only.hpp>
#include <boost/test/unit_test.hpp>
@@ -19,7 +20,7 @@ void normal_function()
normal_function_called=true;
}
-void test_thread_function_no_arguments()
+BOOST_AUTO_TEST_CASE(test_thread_function_no_arguments)
{
boost::thread function(normal_function);
function.join();
@@ -33,7 +34,7 @@ void normal_function_one_arg(int i)
nfoa_res=i;
}
-void test_thread_function_one_argument()
+BOOST_AUTO_TEST_CASE(test_thread_function_one_argument)
{
boost::thread function(normal_function_one_arg,42);
function.join();
@@ -52,7 +53,7 @@ struct callable_no_args
bool callable_no_args::called=false;
-void test_thread_callable_object_no_arguments()
+BOOST_AUTO_TEST_CASE(test_thread_callable_object_no_arguments)
{
callable_no_args func;
boost::thread callable(func);
@@ -74,7 +75,7 @@ struct callable_noncopyable_no_args:
bool callable_noncopyable_no_args::called=false;
-void test_thread_callable_object_ref_no_arguments()
+BOOST_AUTO_TEST_CASE(test_thread_callable_object_ref_no_arguments)
{
callable_noncopyable_no_args func;
@@ -98,7 +99,7 @@ struct callable_one_arg
bool callable_one_arg::called=false;
int callable_one_arg::called_arg=0;
-void test_thread_callable_object_one_argument()
+BOOST_AUTO_TEST_CASE(test_thread_callable_object_one_argument)
{
callable_one_arg func;
boost::thread callable(func,42);
@@ -140,7 +141,7 @@ std::string callable_multiple_arg::called_three_arg1;
std::vector<int> callable_multiple_arg::called_three_arg2;
int callable_multiple_arg::called_three_arg3;
-void test_thread_callable_object_multiple_arguments()
+BOOST_AUTO_TEST_CASE(test_thread_callable_object_multiple_arguments)
{
std::vector<int> x;
for(unsigned i=0;i<7;++i)
@@ -196,7 +197,7 @@ struct X
};
-void test_thread_member_function_no_arguments()
+BOOST_AUTO_TEST_CASE(test_thread_member_function_no_arguments)
{
X x;
@@ -206,29 +207,10 @@ void test_thread_member_function_no_arguments()
}
-void test_thread_member_function_one_argument()
+BOOST_AUTO_TEST_CASE(test_thread_member_function_one_argument)
{
X x;
boost::thread function(&X::f1,&x,42);
function.join();
BOOST_CHECK_EQUAL(42,x.arg_value);
}
-
-
-boost::unit_test::test_suite* init_unit_test_suite(int, char*[])
-{
- boost::unit_test::test_suite* test =
- BOOST_TEST_SUITE("Boost.Threads: thread launching test suite");
-
- test->add(BOOST_TEST_CASE(test_thread_function_no_arguments));
- test->add(BOOST_TEST_CASE(test_thread_function_one_argument));
- test->add(BOOST_TEST_CASE(test_thread_callable_object_no_arguments));
- test->add(BOOST_TEST_CASE(test_thread_callable_object_ref_no_arguments));
- test->add(BOOST_TEST_CASE(test_thread_callable_object_one_argument));
- test->add(BOOST_TEST_CASE(test_thread_callable_object_multiple_arguments));
- test->add(BOOST_TEST_CASE(test_thread_member_function_no_arguments));
- test->add(BOOST_TEST_CASE(test_thread_member_function_one_argument));
- return test;
-}
-
-
diff --git a/libs/thread/test/test_thread_move.cpp b/libs/thread/test/test_thread_move.cpp
index fe01b62fd..e86db8cad 100644
--- a/libs/thread/test/test_thread_move.cpp
+++ b/libs/thread/test/test_thread_move.cpp
@@ -2,6 +2,9 @@
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+#define BOOST_TEST_MODULE Boost.Threads: thread move test suite
+
#include <boost/thread/thread_only.hpp>
#include <boost/test/unit_test.hpp>
@@ -10,7 +13,7 @@ void do_nothing(boost::thread::id* my_id)
*my_id=boost::this_thread::get_id();
}
-void test_move_on_construction()
+BOOST_AUTO_TEST_CASE(test_move_on_construction)
{
boost::thread::id the_id;
boost::thread x=boost::thread(do_nothing,&the_id);
@@ -24,7 +27,7 @@ boost::thread make_thread(boost::thread::id* the_id)
return boost::thread(do_nothing,the_id);
}
-void test_move_from_function_return()
+BOOST_AUTO_TEST_CASE(test_move_from_function_return)
{
boost::thread::id the_id;
boost::thread x=make_thread(&the_id);
@@ -33,7 +36,7 @@ void test_move_from_function_return()
BOOST_CHECK_EQUAL(the_id,x_id);
}
-void test_move_assign()
+BOOST_AUTO_TEST_CASE(test_move_assign)
{
boost::thread::id the_id;
boost::thread x(do_nothing,&the_id);
@@ -44,15 +47,4 @@ void test_move_assign()
BOOST_CHECK_EQUAL(the_id,y_id);
}
-boost::unit_test::test_suite* init_unit_test_suite(int, char*[])
-{
- boost::unit_test::test_suite* test =
- BOOST_TEST_SUITE("Boost.Threads: thread move test suite");
-
- test->add(BOOST_TEST_CASE(test_move_on_construction));
- test->add(BOOST_TEST_CASE(test_move_from_function_return));
- test->add(BOOST_TEST_CASE(test_move_assign));
- return test;
-}
-
diff --git a/libs/thread/test/test_thread_move_return.cpp b/libs/thread/test/test_thread_move_return.cpp
index e9e4512b8..f714fb0a5 100644
--- a/libs/thread/test/test_thread_move_return.cpp
+++ b/libs/thread/test/test_thread_move_return.cpp
@@ -4,6 +4,7 @@
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#define BOOST_THREAD_USES_MOVE
+#define BOOST_TEST_MODULE Boost.Threads: thread move return test suite
#include <boost/thread/thread_only.hpp>
#include <boost/test/unit_test.hpp>
@@ -19,7 +20,7 @@ boost::thread make_thread_move_return(boost::thread::id* the_id)
return boost::move(t);
}
-void test_move_from_function_move_return()
+BOOST_AUTO_TEST_CASE(test_move_from_function_move_return)
{
boost::thread::id the_id;
boost::thread x=make_thread_move_return(&the_id);
@@ -28,13 +29,3 @@ void test_move_from_function_move_return()
BOOST_CHECK_EQUAL(the_id,x_id);
}
-boost::unit_test::test_suite* init_unit_test_suite(int, char*[])
-{
- boost::unit_test::test_suite* test =
- BOOST_TEST_SUITE("Boost.Threads: thread move test suite");
-
- test->add(BOOST_TEST_CASE(test_move_from_function_move_return));
- return test;
-}
-
-
diff --git a/libs/thread/test/test_thread_return_local.cpp b/libs/thread/test/test_thread_return_local.cpp
index 46e84a7e2..6ffd1083a 100644
--- a/libs/thread/test/test_thread_return_local.cpp
+++ b/libs/thread/test/test_thread_return_local.cpp
@@ -5,6 +5,8 @@
#define BOOST_THREAD_USES_MOVE
+#define BOOST_TEST_MODULE Boost.Threads: thread return local test suite
+
#include <boost/thread/thread_only.hpp>
#include <boost/test/unit_test.hpp>
@@ -19,7 +21,7 @@ boost::thread make_thread_return_local(boost::thread::id* the_id)
return boost::move(t);
}
-void test_move_from_function_return_local()
+BOOST_AUTO_TEST_CASE(test_move_from_function_return_local)
{
boost::thread::id the_id;
boost::thread x=make_thread_return_local(&the_id);
@@ -27,14 +29,3 @@ void test_move_from_function_return_local()
x.join();
BOOST_CHECK_EQUAL(the_id,x_id);
}
-
-boost::unit_test::test_suite* init_unit_test_suite(int, char*[])
-{
- boost::unit_test::test_suite* test =
- BOOST_TEST_SUITE("Boost.Threads: thread move test suite");
-
- test->add(BOOST_TEST_CASE(test_move_from_function_return_local));
- return test;
-}
-
-
diff --git a/libs/thread/test/test_tss.cpp b/libs/thread/test/test_tss.cpp
index 595b15620..c833a9fd0 100644
--- a/libs/thread/test/test_tss.cpp
+++ b/libs/thread/test/test_tss.cpp
@@ -7,6 +7,7 @@
#define BOOST_THREAD_VERSION 2
#define BOOST_THREAD_PROVIDES_INTERRUPTIONS
+#define BOOST_TEST_MODULE Boost.Threads: tss test suite
#include <boost/thread/detail/config.hpp>
#include <boost/predef/platform.h>
@@ -73,7 +74,7 @@ void test_tss_thread()
#if BOOST_PLAT_WINDOWS_RUNTIME
typedef std::shared_ptr<std::thread> native_thread_t;
- void test_tss_thread_native()
+ BOOST_AUTO_TEST_CASE(test_tss_thread_native)
{
test_tss_thread();
}
@@ -208,7 +209,7 @@ void do_test_tss()
BOOST_CHECK_EQUAL(tss_total, 5);
}
-void test_tss()
+BOOST_AUTO_TEST_CASE(test_tss)
{
timed_test(&do_test_tss, 2);
}
@@ -224,6 +225,7 @@ void tss_void_custom_cleanup(void* d)
}
boost::thread_specific_ptr<void> tss_void(tss_void_custom_cleanup);
+
void test_tss_void_thread()
{
tss_void.reset(new tss_value_t());
@@ -300,10 +302,10 @@ void do_test_tss_void()
// BOOST_CHECK_EQUAL(tss_total, 5);
}
-void test_tss_void()
-{
- timed_test(&do_test_tss_void, 2);
-}
+//BOOST_AUTO_TEST_CASE(test_tss_void)
+//{
+// timed_test(&do_test_tss_void, 2);
+//}
boost::thread_specific_ptr<void> tss_void_with_cleanup(tss_void_custom_cleanup);
@@ -331,7 +333,7 @@ void do_test_tss_void_with_custom_cleanup()
}
-void test_tss_void_with_custom_cleanup()
+BOOST_AUTO_TEST_CASE(test_tss_void_with_custom_cleanup)
{
timed_test(&do_test_tss_void_with_custom_cleanup, 2);
}
@@ -373,7 +375,7 @@ void do_test_tss_with_custom_cleanup()
}
-void test_tss_with_custom_cleanup()
+BOOST_AUTO_TEST_CASE(test_tss_with_custom_cleanup)
{
timed_test(&do_test_tss_with_custom_cleanup, 2);
}
@@ -450,12 +452,12 @@ void do_test_tss_does_no_cleanup_with_null_cleanup_function()
}
}
-void test_tss_does_no_cleanup_after_release()
+BOOST_AUTO_TEST_CASE(test_tss_does_no_cleanup_after_release)
{
timed_test(&do_test_tss_does_no_cleanup_after_release, 2);
}
-void test_tss_does_no_cleanup_with_null_cleanup_function()
+BOOST_AUTO_TEST_CASE(test_tss_does_no_cleanup_with_null_cleanup_function)
{
timed_test(&do_test_tss_does_no_cleanup_with_null_cleanup_function, 2);
}
@@ -472,14 +474,14 @@ void thread_with_local_tss_ptr()
}
-void test_tss_does_not_call_cleanup_after_ptr_destroyed()
+BOOST_AUTO_TEST_CASE(test_tss_does_not_call_cleanup_after_ptr_destroyed)
{
boost::thread t(thread_with_local_tss_ptr);
t.join();
BOOST_CHECK(!tss_cleanup_called);
}
-void test_tss_cleanup_not_called_for_null_pointer()
+BOOST_AUTO_TEST_CASE(test_tss_cleanup_not_called_for_null_pointer)
{
boost::thread_specific_ptr<Dummy> local_tss(tss_custom_cleanup);
local_tss.reset(new Dummy);
@@ -491,34 +493,16 @@ void test_tss_cleanup_not_called_for_null_pointer()
BOOST_CHECK(!tss_cleanup_called);
}
-void test_tss_at_the_same_adress()
-{
- for(int i=0; i<2; i++)
- {
- boost::thread_specific_ptr<Dummy> local_tss(tss_custom_cleanup);
- local_tss.reset(new Dummy);
- tss_cleanup_called=false;
- BOOST_CHECK(tss_cleanup_called);
- tss_cleanup_called=false;
- BOOST_CHECK(!tss_cleanup_called);
- }
-}
-
-
-boost::unit_test::test_suite* init_unit_test_suite(int, char*[])
-{
- boost::unit_test::test_suite* test =
- BOOST_TEST_SUITE("Boost.Threads: tss test suite");
-
- test->add(BOOST_TEST_CASE(test_tss));
- test->add(BOOST_TEST_CASE(test_tss_with_custom_cleanup));
- test->add(BOOST_TEST_CASE(test_tss_does_no_cleanup_after_release));
- test->add(BOOST_TEST_CASE(test_tss_does_no_cleanup_with_null_cleanup_function));
- test->add(BOOST_TEST_CASE(test_tss_does_not_call_cleanup_after_ptr_destroyed));
- test->add(BOOST_TEST_CASE(test_tss_cleanup_not_called_for_null_pointer));
- //test->add(BOOST_TEST_CASE(test_tss_void));
- test->add(BOOST_TEST_CASE(test_tss_void_with_custom_cleanup));
+//BOOST_AUTO_TEST_CASE(test_tss_at_the_same_adress)
+//{
+// for(int i=0; i<2; i++)
+// {
+// boost::thread_specific_ptr<Dummy> local_tss(tss_custom_cleanup);
+// local_tss.reset(new Dummy);
+// tss_cleanup_called=false;
+// BOOST_CHECK(tss_cleanup_called);
+// tss_cleanup_called=false;
+// BOOST_CHECK(!tss_cleanup_called);
+// }
+//}
-
- return test;
-}
diff --git a/libs/thread/test/test_xtime.cpp b/libs/thread/test/test_xtime.cpp
index f7d79a098..4988d1f86 100644
--- a/libs/thread/test/test_xtime.cpp
+++ b/libs/thread/test/test_xtime.cpp
@@ -6,6 +6,7 @@
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#define BOOST_THREAD_VERSION 2
+#define BOOST_TEST_MODULE Boost.Threads: xtime test suite
#include <boost/thread/detail/config.hpp>
@@ -15,7 +16,7 @@
#include <boost/thread/mutex.hpp>
#include <boost/thread/condition.hpp>
-void test_xtime_cmp()
+BOOST_AUTO_TEST_CASE(test_xtime_cmp)
{
boost::xtime xt1, xt2, cur;
BOOST_CHECK_EQUAL(
@@ -39,7 +40,7 @@ void test_xtime_cmp()
BOOST_CHECK(boost::xtime_cmp(cur, cur) == 0);
}
-void test_xtime_get()
+BOOST_AUTO_TEST_CASE(test_xtime_get)
{
boost::xtime orig, cur, old;
BOOST_CHECK_EQUAL(
@@ -58,7 +59,7 @@ void test_xtime_get()
}
}
-void test_xtime_mutex_backwards_compatibility()
+BOOST_AUTO_TEST_CASE(test_xtime_mutex_backwards_compatibility)
{
boost::timed_mutex m;
BOOST_CHECK(m.timed_lock(boost::get_xtime(boost::get_system_time()+boost::posix_time::milliseconds(10))));
@@ -82,7 +83,7 @@ bool predicate()
}
-void test_xtime_condvar_backwards_compatibility()
+BOOST_AUTO_TEST_CASE(test_xtime_condvar_backwards_compatibility)
{
boost::condition_variable cond;
boost::condition_variable_any cond_any;
@@ -94,18 +95,3 @@ void test_xtime_condvar_backwards_compatibility()
cond_any.timed_wait(lk,boost::get_xtime(boost::get_system_time()+boost::posix_time::milliseconds(10)));
cond_any.timed_wait(lk,boost::get_xtime(boost::get_system_time()+boost::posix_time::milliseconds(10)),predicate);
}
-
-
-
-boost::unit_test::test_suite* init_unit_test_suite(int, char*[])
-{
- boost::unit_test::test_suite* test =
- BOOST_TEST_SUITE("Boost.Threads: xtime test suite");
-
- test->add(BOOST_TEST_CASE(&test_xtime_cmp));
- test->add(BOOST_TEST_CASE(&test_xtime_get));
- test->add(BOOST_TEST_CASE(&test_xtime_mutex_backwards_compatibility));
- test->add(BOOST_TEST_CASE(&test_xtime_condvar_backwards_compatibility));
-
- return test;
-}
diff --git a/libs/thread/test/winrt_init.cpp b/libs/thread/test/winrt_init.cpp
index 99edd8b51..b6d0864ba 100644
--- a/libs/thread/test/winrt_init.cpp
+++ b/libs/thread/test/winrt_init.cpp
@@ -1,3 +1,5 @@
+// Copyright (C) 2014 Vicente Botet
+//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)