Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r84548 - in trunk/libs/thread/test: . sync/futures/shared_future
From: vicente.botet_at_[hidden]
Date: 2013-05-29 16:48:38


Author: viboes
Date: 2013-05-29 16:48:37 EDT (Wed, 29 May 2013)
New Revision: 84548
URL: http://svn.boost.org/trac/boost/changeset/84548

Log:
Thread added shared_future::then tests.
Added:
   trunk/libs/thread/test/sync/futures/shared_future/then_pass.cpp (contents, props changed)
Text files modified:
   trunk/libs/thread/test/Jamfile.v2 | 16 ++++++++++++++++
   1 files changed, 16 insertions(+), 0 deletions(-)

Modified: trunk/libs/thread/test/Jamfile.v2
==============================================================================
--- trunk/libs/thread/test/Jamfile.v2 (original)
+++ trunk/libs/thread/test/Jamfile.v2 2013-05-29 16:48:37 EDT (Wed, 29 May 2013)
@@ -66,6 +66,14 @@
         #<toolset>darwin-4.6.2:<cxxflags>-Wno-delete-non-virtual-dtor # doesn't work
         <toolset>darwin-4.7.0:<cxxflags>-ansi
         <toolset>darwin-4.7.0:<cxxflags>-Wno-delete-non-virtual-dtor
+ #<toolset>darwin-4.6.2:<cxxflags>-Wno-unused-local-typedefs
+ #<toolset>darwin-4.7.1:<cxxflags>-Wno-unused-local-typedefs
+ #<toolset>darwin-4.7.2:<cxxflags>-Wno-unused-local-typedefs
+ #<toolset>darwin-4.8.0:<cxxflags>-Wno-unused-local-typedefs
+ #<toolset>darwin-4.6.2x:<cxxflags>-Wno-unused-local-typedefs
+ #<toolset>darwin-4.7.1x:<cxxflags>-Wno-unused-local-typedefs
+ #<toolset>darwin-4.7.2x:<cxxflags>-Wno-unused-local-typedefs
+ #<toolset>darwin-4.8.0x:<cxxflags>-Wno-unused-local-typedefs
 
         #<toolset>clang-2.8:<cxxflags>-Wno-delete-non-virtual-dtor
         #<toolset>clang-2.8:<cxxflags>-Wno-unused-function
@@ -74,6 +82,8 @@
         <toolset>clang-3.0:<cxxflags>-Wno-delete-non-virtual-dtor
         #<toolset>clang-3.0:<cxxflags>-Wno-unused-function
         #<toolset>clang-3.0:<cxxflags>-Wno-unused-variable
+ #<toolset>clang-3.1:<cxxflags>-Wno-bind-to-temporary-copy
+ #<toolset>clang-3.2:<cxxflags>-Wno-bind-to-temporary-copy
 
 # Note: Some of the remarks from the Intel compiler are disabled
 # remark #193: zero used for undefined preprocessing identifier "XXX"
@@ -364,6 +374,7 @@
           [ thread-run2-noit ./sync/futures/shared_future/wait_pass.cpp : shared_future__wait_p ]
           [ thread-run2-noit ./sync/futures/shared_future/wait_for_pass.cpp : shared_future__wait_for_p ]
           [ thread-run2-noit ./sync/futures/shared_future/wait_until_pass.cpp : shared_future__wait_until_p ]
+ [ thread-run2-noit ./sync/futures/shared_future/then_pass.cpp : shared_future__then_p ]
     ;
 
     #explicit ts_packaged_task ;
@@ -759,6 +770,11 @@
           #[ thread-run ../example/perf_condition_variable.cpp ]
           #[ thread-run ../example/perf_shared_mutex.cpp ]
           #[ thread-run ../example/std_async_test.cpp ]
+ #[ thread-run test_8508.cpp ]
+ #[ thread-run test_8586.cpp ]
+ #[ thread-run test_8596.cpp ]
+ #[ thread-run test_8600.cpp ]
+
     ;
 
 }

Added: trunk/libs/thread/test/sync/futures/shared_future/then_pass.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/thread/test/sync/futures/shared_future/then_pass.cpp 2013-05-29 16:48:37 EDT (Wed, 29 May 2013)
@@ -0,0 +1,97 @@
+// Copyright (C) 2012-2013 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)
+
+// <boost/thread/future.hpp>
+
+// class future<R>
+
+// template<typename F>
+// auto then(F&& func) -> future<decltype(func(*this))>;
+
+#define BOOST_THREAD_VERSION 4
+#define BOOST_THREAD_USES_LOG
+#define BOOST_THREAD_USES_LOG_THREAD_ID
+#include <boost/thread/detail/log.hpp>
+
+#include <boost/thread/future.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+#if defined BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION
+
+int p1()
+{
+ BOOST_THREAD_LOG << "p1 < " << BOOST_THREAD_END_LOG;
+ boost::this_thread::sleep_for(boost::chrono::milliseconds(500));
+ BOOST_THREAD_LOG << "p1 >" << BOOST_THREAD_END_LOG;
+ return 1;
+}
+
+int p2(boost::shared_future<int>& f)
+{
+ BOOST_THREAD_LOG << "p2 <" << &f << BOOST_THREAD_END_LOG;
+ BOOST_TEST(f.valid());
+ int i = f.get();
+ boost::this_thread::sleep_for(boost::chrono::milliseconds(500));
+ BOOST_THREAD_LOG << "p2 <" << &f << BOOST_THREAD_END_LOG;
+ return 2 * i;
+}
+
+int main()
+{
+ {
+ 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<int> f2 = f1.then(&p2);
+ BOOST_TEST(f2.valid());
+ try
+ {
+ BOOST_TEST(f2.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::future<int> f2 = boost::async(p1).share().then(&p2);
+ BOOST_TEST(f2.get()==2);
+ }
+ BOOST_THREAD_LOG << BOOST_THREAD_END_LOG;
+ {
+ boost::shared_future<int> f1 = boost::async(p1).share();
+ boost::shared_future<int> f21 = f1.then(&p2).share();
+ boost::future<int> f2= f21.then(&p2);
+ BOOST_TEST(f2.get()==4);
+ }
+ BOOST_THREAD_LOG << BOOST_THREAD_END_LOG;
+ {
+ boost::shared_future<int> f1 = boost::async(p1).share();
+ boost::future<int> f2= f1.then(&p2).share().then(&p2);
+ BOOST_TEST(f2.get()==4);
+ }
+ BOOST_THREAD_LOG << BOOST_THREAD_END_LOG;
+ {
+ boost::future<int> f2 = boost::async(p1).share().then(&p2).share().then(&p2);
+ BOOST_TEST(f2.get()==4);
+ }
+
+ return boost::report_errors();
+}
+
+#else
+
+int main()
+{
+ return 0;
+}
+#endif


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