summaryrefslogtreecommitdiff
path: root/libs/thread/example
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2016-10-06 10:30:07 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2016-10-06 10:32:57 +0900
commit71d216b90256936a9638f325af9bc69d720e75de (patch)
tree9c5f682d341c7c88ad0c8e3d4b262e00b6fb691a /libs/thread/example
parent733b5d5ae2c5d625211e2985ac25728ac3f54883 (diff)
downloadboost-71d216b90256936a9638f325af9bc69d720e75de.tar.gz
boost-71d216b90256936a9638f325af9bc69d720e75de.tar.bz2
boost-71d216b90256936a9638f325af9bc69d720e75de.zip
Imported Upstream version 1.59.0
Change-Id: I2dde00f4eca71df3eea9d251dcaecde18a6c90a5 Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
Diffstat (limited to 'libs/thread/example')
-rw-r--r--libs/thread/example/executor.cpp16
-rw-r--r--libs/thread/example/lambda_future.cpp8
2 files changed, 24 insertions, 0 deletions
diff --git a/libs/thread/example/executor.cpp b/libs/thread/example/executor.cpp
index 7f6b1ce3e0..10c77a0007 100644
--- a/libs/thread/example/executor.cpp
+++ b/libs/thread/example/executor.cpp
@@ -28,6 +28,10 @@
#include <string>
#include <iostream>
+boost::future<void> p(boost::future<void>) {
+ return boost::make_ready_future();
+}
+
void p1()
{
// std::cout << BOOST_CONTEXTOF << std::endl;
@@ -147,4 +151,16 @@ int test_executor_adaptor()
int main()
{
return test_executor_adaptor();
+
+#if defined BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION \
+ && defined BOOST_THREAD_PROVIDES_EXECUTORS \
+ && ! defined BOOST_NO_CXX11_RVALUE_REFERENCES
+
+ // compiles
+ boost::make_ready_future().then(&p);
+
+ boost::basic_thread_pool executor;
+ // doesn't compile
+ boost::make_ready_future().then(executor, &p);
+#endif
}
diff --git a/libs/thread/example/lambda_future.cpp b/libs/thread/example/lambda_future.cpp
index 6df1cee7f7..fd15d44840 100644
--- a/libs/thread/example/lambda_future.cpp
+++ b/libs/thread/example/lambda_future.cpp
@@ -42,6 +42,14 @@ int main()
int result = f2.get();
BOOST_THREAD_LOG << "f2 " << result << BOOST_THREAD_END_LOG;
}
+#if ! defined BOOST_NO_CXX14_GENERIC_LAMBDAS
+ {
+ boost::future<int> f1 = boost::async(boost::launch::async, []() {return 123;});
+ boost::future<int> f2 = f1.then([](auto f) {return 2*f.get(); });
+ int result = f2.get();
+ BOOST_THREAD_LOG << "f2 " << result << BOOST_THREAD_END_LOG;
+ }
+#endif
}
catch (std::exception& ex)
{