int main() { std::cout << BOOST_CONTEXTOF << std::endl; { try { boost::executor_adaptor<boost::thread_pool> ea; submit_some(ea); { boost::future<int> t1 = boost::async(ea, &f1); boost::future<int> t2 = boost::async(ea, &f1); std::cout << BOOST_CONTEXTOF << " t1= " << t1.get() << std::endl; std::cout << BOOST_CONTEXTOF << " t2= " << t2.get() << std::endl; } submit_some(ea); { boost::thread_pool ea3(1); boost::future<int> t1 = boost::async(ea3, &f1); boost::future<int> t2 = boost::async(ea3, &f1); //boost::future<int> t2 = boost::async(ea3, f2, 1); // todo this doesn't compiles yet on C++11 //boost::future<int> t2 = boost::async(ea3, boost::bind(f2, 1)); // todo this doesn't compiles yet on C++98 std::cout << BOOST_CONTEXTOF << " t1= " << t1.get() << std::endl; std::cout << BOOST_CONTEXTOF << " t2= " << t2.get() << std::endl; } submit_some(ea); boost::executor_adaptor<boost::user_scheduler> ea2; submit_some(ea2); ea2.underlying_executor().run_queued_closures(); } catch (std::exception& ex) { std::cout << "ERROR= " << ex.what() << "" << std::endl; return 1; } catch (...) { std::cout << " ERROR= exception thrown" << std::endl; return 2; } } std::cout << BOOST_CONTEXTOF << std::endl; return 0; }
int test_generic_executor_ref() { // std::cout << BOOST_CONTEXTOF << std::endl; { try { { boost::basic_thread_pool ea(4); submit_some( ea); { boost::future<int> t1 = boost::async(ea, &f1); boost::future<int> t2 = boost::async(ea, &f1); // std::cout << BOOST_CONTEXTOF << " t1= " << t1.get() << std::endl; // std::cout << BOOST_CONTEXTOF << " t2= " << t2.get() << std::endl; } submit_some(ea); { boost::basic_thread_pool ea3(1); boost::future<int> t1 = boost::async(ea3, &f1); boost::future<int> t2 = boost::async(ea3, &f1); //boost::future<int> t2 = boost::async(ea3, f2, 1); // todo this doesn't compiles yet on C++11 //boost::future<int> t2 = boost::async(ea3, boost::bind(f2, 1)); // todo this doesn't compiles yet on C++98 // std::cout << BOOST_CONTEXTOF << " t1= " << t1.get() << std::endl; // std::cout << BOOST_CONTEXTOF << " t2= " << t2.get() << std::endl; } submit_some(ea); } // std::cout << BOOST_CONTEXTOF << std::endl; { boost::loop_executor ea2; submit_some( ea2); ea2.run_queued_closures(); } #if ! defined(BOOST_NO_CXX11_RVALUE_REFERENCES) // std::cout << BOOST_CONTEXTOF << std::endl; { boost::basic_thread_pool ea1(4); boost::serial_executor ea2(ea1); submit_some(ea2); } #endif // std::cout << BOOST_CONTEXTOF << std::endl; { boost::inline_executor ea1; submit_some(ea1); } // std::cout << BOOST_CONTEXTOF << std::endl; { //boost::thread_executor ea1; //submit_some(ea1); } // std::cout << BOOST_CONTEXTOF << std::endl; { boost::basic_thread_pool ea(4, at_th_entry); boost::future<int> t1 = boost::async(ea, &f1); // std::cout << BOOST_CONTEXTOF << " t1= " << t1.get() << std::endl; } } catch (std::exception& ex) { std::cout << "ERROR= " << ex.what() << "" << std::endl; return 1; } catch (...) { std::cout << " ERROR= exception thrown" << std::endl; return 2; } } // std::cout << BOOST_CONTEXTOF << std::endl; return 0; }