diff options
Diffstat (limited to 'src/boost/libs/thread/test/test_9711.cpp')
-rw-r--r-- | src/boost/libs/thread/test/test_9711.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/boost/libs/thread/test/test_9711.cpp b/src/boost/libs/thread/test/test_9711.cpp new file mode 100644 index 00000000..d8fd8e3e --- /dev/null +++ b/src/boost/libs/thread/test/test_9711.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_PROVIDES_FUTURE +#define BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION +#include <boost/config.hpp> +#if ! defined BOOST_NO_CXX11_DECLTYPE +#define BOOST_RESULT_OF_USE_DECLTYPE +#endif + +#include <boost/thread/future.hpp> + + +int main() +{ +#if ! defined BOOST_NO_CXX11_LAMBDAS && ! (defined BOOST_MSVC && _MSC_VER < 1700) + boost::promise<int> prom; + boost::future<int> futr = prom.get_future(); + + int callCount = 0; + + boost::future<void> futr2 = futr.then(boost::launch::deferred, + [&] (boost::future<int> f) { + callCount++; + assert(f.valid()); + assert(f.is_ready()); + assert(17 == f.get()); + }); + + assert(futr2.valid()); + assert(!futr2.is_ready()); + assert(0 == callCount); + + prom.set_value(17); + assert(0 == callCount); + + futr2.get(); + assert(1 == callCount); + +#endif + return 0; +} |