int main() { { boost::future<int> f = compute(2); std::cout << f.get() << std::endl; } { boost::shared_future<int> f = shared_compute(2); std::cout << f.get() << std::endl; } return 0; }
int main() { #if defined BOOST_THREAD_USES_MOVE { boost::future<void> f = void_compute(); f.get(); } #endif { boost::future<int> f = compute(2); std::cout << f.get() << std::endl; } { boost::future<int> f = compute(0); std::cout << f.get() << std::endl; } { boost::shared_future<int> f = shared_compute(2); std::cout << f.get() << std::endl; } return 0; }
int main() { const int number_of_tests = 100; for (int i=0; i< number_of_tests; i++) try { #if defined BOOST_THREAD_USES_MOVE { boost::future<void> f = void_compute(); f.get(); } #endif { boost::future<int> f = compute(2); std::cout << f.get() << std::endl; } { boost::future<int> f = compute(0); std::cout << f.get() << std::endl; } { boost::shared_future<int> f = shared_compute(2); 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; }
int main() { const int number_of_tests = 100; for (int i=0; i< number_of_tests; i++) try { // { // std::cout << __FILE__ << " "<<__LINE__ << std::endl; // boost::future<int> f = boost::async(boost::launch::async, p1); // std::cout << i << " "<<f.get() << std::endl; // } #if defined BOOST_THREAD_USES_MOVE { std::cout << __FILE__ << " "<< __LINE__ << std::endl; boost::future<void> f = void_compute(); f.get(); } #endif { std::cout << __FILE__ << " "<< __LINE__ << std::endl; boost::future<int> f = compute(-1); f.wait(); } { 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_ref(0); std::cout << f.get() << std::endl; } #if __cplusplus > 201103L { std::cout << __FILE__ << " "<< __LINE__ << std::endl; int i = 0; boost::future<int&> f = boost::make_ready_future(std::ref(i)); std::cout << f.get() << std::endl; } #endif { std::cout << __FILE__ << " "<< __LINE__ << std::endl; int i = 0; boost::future<int&> f = boost::make_ready_future(boost::ref(i)); std::cout << f.get() << std::endl; } { std::cout << __FILE__ << " "<< __LINE__ << std::endl; const int i = 0; boost::future<int const&> f = boost::make_ready_future(boost::cref(i)); std::cout << f.get() << std::endl; } { std::cout << __FILE__ << " "<< __LINE__ << std::endl; boost::future<int> f = compute(2); std::cout << f.get() << std::endl; } { 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; }