|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r83503 - in trunk/libs/thread/test/sync/futures: packaged_task promise
From: vicente.botet_at_[hidden]
Date: 2013-03-19 18:35:50
Author: viboes
Date: 2013-03-19 18:35:50 EDT (Tue, 19 Mar 2013)
New Revision: 83503
URL: http://svn.boost.org/trac/boost/changeset/83503
Log:
Thread: protect some tests with BOOST_THREAD_PROVIDES_VARIADIC_THREAD.
Text files modified:
trunk/libs/thread/test/sync/futures/packaged_task/make_ready_at_thread_exit_pass.cpp | 12 ++++++-
trunk/libs/thread/test/sync/futures/promise/set_value_at_thread_exit_void_pass.cpp | 61 +++++++++++++++++++--------------------
2 files changed, 40 insertions(+), 33 deletions(-)
Modified: trunk/libs/thread/test/sync/futures/packaged_task/make_ready_at_thread_exit_pass.cpp
==============================================================================
--- trunk/libs/thread/test/sync/futures/packaged_task/make_ready_at_thread_exit_pass.cpp (original)
+++ trunk/libs/thread/test/sync/futures/packaged_task/make_ready_at_thread_exit_pass.cpp 2013-03-19 18:35:50 EDT (Tue, 19 Mar 2013)
@@ -57,12 +57,17 @@
}
};
+void func0_mv(BOOST_THREAD_RV_REF(boost::packaged_task<double(int, char)>) p)
+//void func0(boost::packaged_task<double(int, char)> p)
+{
+ boost::this_thread::sleep_for(boost::chrono::milliseconds(500));
+ p.make_ready_at_thread_exit(3, 'a');
+}
void func0(boost::packaged_task<double(int, char)> *p)
{
boost::this_thread::sleep_for(boost::chrono::milliseconds(500));
p->make_ready_at_thread_exit(3, 'a');
}
-
void func1(boost::packaged_task<double(int, char)> *p)
{
boost::this_thread::sleep_for(boost::chrono::milliseconds(500));
@@ -99,8 +104,11 @@
{
boost::packaged_task<double(int, char)> p(A(5));
boost::future<double> f = p.get_future();
- // fixme BUG boost::thread(func0, boost::move(p)).detach();
+#if defined BOOST_THREAD_PROVIDES_VARIADIC_THREAD
+ boost::thread(func0_mv, boost::move(p)).detach();
+#else
boost::thread(func0, &p).detach();
+#endif
BOOST_TEST(f.get() == 105.0);
}
{
Modified: trunk/libs/thread/test/sync/futures/promise/set_value_at_thread_exit_void_pass.cpp
==============================================================================
--- trunk/libs/thread/test/sync/futures/promise/set_value_at_thread_exit_void_pass.cpp (original)
+++ trunk/libs/thread/test/sync/futures/promise/set_value_at_thread_exit_void_pass.cpp 2013-03-19 18:35:50 EDT (Tue, 19 Mar 2013)
@@ -19,11 +19,8 @@
// void promise<void>::set_value_at_thread_exit();
#define BOOST_THREAD_VERSION 4
-#define BOOST_THREAD_USES_LOG
-#define BOOST_THREAD_USES_LOG_THREAD_ID
#include <boost/thread/future.hpp>
-#include <boost/thread/detail/log.hpp>
#include <boost/detail/lightweight_test.hpp>
int i = 0;
@@ -35,12 +32,17 @@
i = 1;
}
-void func2(boost::promise<void> p2)
+void func2_mv(BOOST_THREAD_RV_REF(boost::promise<void>) p2)
{
p2.set_value_at_thread_exit();
i = 2;
}
+void func2(boost::promise<void> *p2)
+{
+ p2->set_value_at_thread_exit();
+ i = 2;
+}
int main()
{
try
@@ -51,7 +53,7 @@
BOOST_TEST(i == 1);
}
- catch(std::exception ex)
+ catch(std::exception& ex)
{
BOOST_TEST(false);
}
@@ -70,7 +72,29 @@
BOOST_TEST(i == 1);
}
- catch(std::exception ex)
+ catch(std::exception& ex)
+ {
+ std::cout << __FILE__ << ":" << __LINE__ << " " << ex.what() << std::endl;
+ BOOST_TEST(false);
+ }
+ catch(...)
+ {
+ BOOST_TEST(false);
+ }
+
+ try
+ {
+ boost::promise<void> p2;
+ boost::future<void> f = p2.get_future();
+#if defined BOOST_THREAD_PROVIDES_VARIADIC_THREAD
+ boost::thread(func2_mv, boost::move(p2)).detach();
+#else
+ boost::thread(func2, &p2).detach();
+#endif
+ f.wait();
+ BOOST_TEST(i == 2);
+ }
+ catch(std::exception& ex)
{
std::cout << __FILE__ << ":" << __LINE__ << " " << ex.what() << std::endl;
BOOST_TEST(false);
@@ -79,31 +103,6 @@
{
BOOST_TEST(false);
}
- // BUG when moving promise. fixme
-// try
-// {
-// BOOST_THREAD_LOG << BOOST_THREAD_END_LOG
-// boost::promise<void> p2; // BUG
-// BOOST_THREAD_LOG << BOOST_THREAD_END_LOG
-// boost::future<void> f = p2.get_future();
-// BOOST_THREAD_LOG << BOOST_THREAD_END_LOG
-// boost::thread(func2, boost::move(p2)).detach(); // BUG
-// BOOST_THREAD_LOG << BOOST_THREAD_END_LOG
-// f.get();
-// BOOST_THREAD_LOG << BOOST_THREAD_END_LOG
-// BOOST_TEST(i == 2);
-// BOOST_THREAD_LOG << BOOST_THREAD_END_LOG
-//
-// }
-// catch(std::exception ex)
-// {
-// std::cout << __FILE__ << ":" << __LINE__ << " " << ex.what() << std::endl;
-// BOOST_TEST(false);
-// }
-// catch(...)
-// {
-// BOOST_TEST(false);
-// }
return boost::report_errors();
}
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk