// 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) #include #if ! defined BOOST_NO_CXX11_DECLTYPE #define BOOST_RESULT_OF_USE_DECLTYPE #endif #define BOOST_THREAD_VERSION 4 //#define BOOST_THREAD_USES_LOG #define BOOST_THREAD_USES_LOG_THREAD_ID #include #include #include #include #if defined BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION int p1() { BOOST_THREAD_LOG << "P1" << BOOST_THREAD_END_LOG; return 123; } int p2(boost::future f) { BOOST_THREAD_LOG << "P2<" << BOOST_THREAD_END_LOG; try { return 2 * f.get(); } catch (std::exception& ex) { std::cout << "ERRORRRRR "<" << BOOST_THREAD_END_LOG; return 0; } int p2s(boost::shared_future f) { BOOST_THREAD_LOG << "" << BOOST_THREAD_END_LOG; return 0; } int main() { const int number_of_tests = 100; BOOST_THREAD_LOG << " f1 = boost::async(&p1); BOOST_THREAD_LOG << "" << BOOST_THREAD_END_LOG; boost::future 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) { std::cout << "ERRORRRRR "< f1 = boost::async(&p1).share(); BOOST_THREAD_LOG << "" << BOOST_THREAD_END_LOG; boost::future 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) { std::cout << "ERRORRRRR "<" << BOOST_THREAD_END_LOG; return 0; } #else int main() { return 0; } #endif