|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r86444 - trunk/libs/thread/example
From: vicente.botet_at_[hidden]
Date: 2013-10-26 07:22:15
Author: viboes
Date: 2013-10-26 07:22:14 EDT (Sat, 26 Oct 2013)
New Revision: 86444
URL: http://svn.boost.org/trac/boost/changeset/86444
Log:
Thread: Add a loop to catch more quickly the multiple bugs on boost::future experimental features and see which tester are failing.
Text files modified:
trunk/libs/thread/example/future_fallback_to.cpp | 17 ++++++-
trunk/libs/thread/example/future_then.cpp | 86 ++++++++++++++++++++++-----------------
trunk/libs/thread/example/future_unwrap.cpp | 1
trunk/libs/thread/example/lambda_future.cpp | 1
trunk/libs/thread/example/make_future.cpp | 29 +++++++++++--
5 files changed, 89 insertions(+), 45 deletions(-)
Modified: trunk/libs/thread/example/future_fallback_to.cpp
==============================================================================
--- trunk/libs/thread/example/future_fallback_to.cpp Sat Oct 26 06:23:00 2013 (r86443)
+++ trunk/libs/thread/example/future_fallback_to.cpp 2013-10-26 07:22:14 EDT (Sat, 26 Oct 2013) (r86444)
@@ -31,11 +31,17 @@
{
BOOST_THREAD_LOG << "<MAIN" << BOOST_THREAD_END_LOG;
{
+ for (int i=0; i< 100; i++)
try
{
- boost::future<int> f1 = boost::async(boost::launch::async, &p1);
+ //boost::future<int> f1 = boost::async(boost::launch::async, &p1);
+ BOOST_THREAD_LOG << "" << BOOST_THREAD_END_LOG;
+ boost::future<int> f1 = boost::async(&p1);
+ BOOST_THREAD_LOG << "" << BOOST_THREAD_END_LOG;
boost::future<int> f2 = f1.fallback_to(-1);
- assert(f2.get()==1);
+ BOOST_THREAD_LOG << "" << BOOST_THREAD_END_LOG;
+ BOOST_ASSERT(f2.get()==1);
+ BOOST_THREAD_LOG << "" << BOOST_THREAD_END_LOG;
}
catch (std::exception& ex)
{
@@ -49,11 +55,16 @@
}
}
{
+ for (int i=0; i< 100; i++)
try
{
+ BOOST_THREAD_LOG << "" << BOOST_THREAD_END_LOG;
boost::future<int> f1 = boost::async(boost::launch::async, &p1_ex);
+ BOOST_THREAD_LOG << "" << BOOST_THREAD_END_LOG;
boost::future<int> f2 = f1.fallback_to(-1);
- assert(f2.get()==-1);
+ BOOST_THREAD_LOG << "" << BOOST_THREAD_END_LOG;
+ BOOST_ASSERT(f2.get()==-1);
+ BOOST_THREAD_LOG << "" << BOOST_THREAD_END_LOG;
}
catch (std::exception& ex)
{
Modified: trunk/libs/thread/example/future_then.cpp
==============================================================================
--- trunk/libs/thread/example/future_then.cpp Sat Oct 26 06:23:00 2013 (r86443)
+++ trunk/libs/thread/example/future_then.cpp 2013-10-26 07:22:14 EDT (Sat, 26 Oct 2013) (r86444)
@@ -21,7 +21,7 @@
int p2(boost::future<int> f)
{
- BOOST_THREAD_LOG << "<P2" << BOOST_THREAD_END_LOG;
+ BOOST_THREAD_LOG << "P2<" << BOOST_THREAD_END_LOG;
try
{
return 2 * f.get();
@@ -40,7 +40,7 @@
}
int p2s(boost::shared_future<int> f)
{
- BOOST_THREAD_LOG << "<P2" << BOOST_THREAD_END_LOG;
+ BOOST_THREAD_LOG << "<P2S" << BOOST_THREAD_END_LOG;
try
{
return 2 * f.get();
@@ -55,47 +55,59 @@
BOOST_THREAD_LOG << " ERRORRRRR exception thrown" << BOOST_THREAD_END_LOG;
BOOST_ASSERT(false);
}
- BOOST_THREAD_LOG << "P2>" << BOOST_THREAD_END_LOG;
+ BOOST_THREAD_LOG << "P2S>" << BOOST_THREAD_END_LOG;
}
int main()
{
BOOST_THREAD_LOG << "<MAIN" << BOOST_THREAD_END_LOG;
{
- try
- {
- boost::future<int> f1 = boost::async(boost::launch::async, &p1);
- boost::future<int> f2 = f1.then(&p2);
- (void)f2.get();
- }
- catch (std::exception& ex)
- {
- BOOST_THREAD_LOG << "ERRORRRRR "<<ex.what() << "" << BOOST_THREAD_END_LOG;
- return 1;
- }
- catch (...)
- {
- BOOST_THREAD_LOG << " ERRORRRRR exception thrown" << BOOST_THREAD_END_LOG;
- return 2;
- }
- }
- {
- try
- {
- boost::shared_future<int> f1 = boost::async(boost::launch::async, &p1).share();
- boost::future<int> f2 = f1.then(&p2s);
- (void)f2.get();
- }
- catch (std::exception& ex)
- {
- BOOST_THREAD_LOG << "ERRORRRRR "<<ex.what() << "" << BOOST_THREAD_END_LOG;
- return 1;
- }
- catch (...)
- {
- BOOST_THREAD_LOG << " ERRORRRRR exception thrown" << BOOST_THREAD_END_LOG;
- return 2;
- }
+ for (int i=0; i< 10; i++)
+ try
+ {
+ BOOST_THREAD_LOG << "" << BOOST_THREAD_END_LOG;
+ //boost::future<int> f1 = boost::async(boost::launch::async, &p1);
+ boost::future<int> f1 = boost::async(&p1);
+ BOOST_THREAD_LOG << "" << BOOST_THREAD_END_LOG;
+ boost::future<int> f2 = f1.then(&p2);
+ BOOST_THREAD_LOG << "" << BOOST_THREAD_END_LOG;
+ (void)f2.get();
+ BOOST_THREAD_LOG << "" << BOOST_THREAD_END_LOG;
+ }
+ catch (std::exception& ex)
+ {
+ BOOST_THREAD_LOG << "ERRORRRRR "<<ex.what() << "" << BOOST_THREAD_END_LOG;
+ return 1;
+ }
+ catch (...)
+ {
+ BOOST_THREAD_LOG << " ERRORRRRR exception thrown" << BOOST_THREAD_END_LOG;
+ return 2;
+ }
+ }
+ {
+ for (int i=0; i< 10; i++)
+ try
+ {
+ BOOST_THREAD_LOG << "" << BOOST_THREAD_END_LOG;
+ //boost::shared_future<int> f1 = boost::async(boost::launch::async, &p1).share();
+ boost::shared_future<int> f1 = boost::async(&p1).share();
+ BOOST_THREAD_LOG << "" << BOOST_THREAD_END_LOG;
+ boost::future<int> f2 = f1.then(&p2s);
+ BOOST_THREAD_LOG << "" << BOOST_THREAD_END_LOG;
+ (void)f2.get();
+ BOOST_THREAD_LOG << "" << BOOST_THREAD_END_LOG;
+ }
+ catch (std::exception& ex)
+ {
+ BOOST_THREAD_LOG << "ERRORRRRR "<<ex.what() << "" << BOOST_THREAD_END_LOG;
+ return 1;
+ }
+ catch (...)
+ {
+ BOOST_THREAD_LOG << " ERRORRRRR exception thrown" << BOOST_THREAD_END_LOG;
+ return 2;
+ }
}
BOOST_THREAD_LOG << "MAIN>" << BOOST_THREAD_END_LOG;
return 0;
Modified: trunk/libs/thread/example/future_unwrap.cpp
==============================================================================
--- trunk/libs/thread/example/future_unwrap.cpp Sat Oct 26 06:23:00 2013 (r86443)
+++ trunk/libs/thread/example/future_unwrap.cpp 2013-10-26 07:22:14 EDT (Sat, 26 Oct 2013) (r86444)
@@ -30,6 +30,7 @@
int main()
{
BOOST_THREAD_LOG << "<MAIN" << BOOST_THREAD_END_LOG;
+ for (int i=0; i< 10; i++)
try
{
boost::future<boost::future<int> > outer_future = boost::async(boost::launch::async, &p2);
Modified: trunk/libs/thread/example/lambda_future.cpp
==============================================================================
--- trunk/libs/thread/example/lambda_future.cpp Sat Oct 26 06:23:00 2013 (r86443)
+++ trunk/libs/thread/example/lambda_future.cpp 2013-10-26 07:22:14 EDT (Sat, 26 Oct 2013) (r86444)
@@ -24,6 +24,7 @@
{
BOOST_THREAD_LOG << "<MAIN" << BOOST_THREAD_END_LOG;
+ for (int i=0; i< 10; i++)
try
{
{
Modified: trunk/libs/thread/example/make_future.cpp
==============================================================================
--- trunk/libs/thread/example/make_future.cpp Sat Oct 26 06:23:00 2013 (r86443)
+++ trunk/libs/thread/example/make_future.cpp 2013-10-26 07:22:14 EDT (Sat, 26 Oct 2013) (r86444)
@@ -35,7 +35,8 @@
//if (x < 0) return boost::make_ready_future<int>(boost::make_exception_ptr(std::logic_error("Error")));
if (x < 0) return boost::make_ready_future<int>(std::logic_error("Error"));
//boost::future<int> f1 = boost::async([]() { return x+1; });
- boost::future<int> f1 = boost::async(boost::launch::async, p1);
+ //boost::future<int> f1 = boost::async(boost::launch::async, &p1);
+ boost::future<int> f1 = boost::async(p1);
return boost::move(f1);
}
boost::shared_future<int> shared_compute(int x)
@@ -43,30 +44,48 @@
if (x == 0) return boost::make_ready_future(0).share();
if (x < 0) return boost::make_ready_future<int>(std::logic_error("Error")).share();
//boost::future<int> f1 = boost::async([]() { return x+1; });
- boost::shared_future<int> f1 = boost::async(p1).share();
- return boost::move(f1);
+ boost::shared_future<int> f1 = boost::async(&p1).share();
+ return f1;
}
int main()
{
+ for (int i=0; i< 10; i++)
+ try
+ {
#if defined BOOST_THREAD_USES_MOVE
{
+ std::cout << __FILE__ << " "<< __LINE__ << std::endl;
boost::future<void> f = void_compute();
f.get();
}
#endif
{
- boost::future<int> f = compute(2);
+ std::cout << __FILE__ << " "<< __LINE__ << std::endl;
+ boost::future<int> f = compute(0);
std::cout << f.get() << std::endl;
}
{
+ std::cout << __FILE__ << " "<< __LINE__ << std::endl;
boost::future<int> f = compute(0);
std::cout << f.get() << std::endl;
}
{
- boost::shared_future<int> f = shared_compute(2);
+ std::cout << __FILE__ << " "<< __LINE__ << std::endl;
+ boost::shared_future<int> f = shared_compute(0);
std::cout << f.get() << std::endl;
}
+ }
+ catch (std::exception& ex)
+ {
+ std::cout << "ERRORRRRR "<<ex.what() << "" << std::endl;
+ return 1;
+ }
+ catch (...)
+ {
+ std::cout << "ERRORRRRR "<<"ERRORRRRR exception thrown" << std::endl;
+ return 2;
+ }
return 0;
}
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