int main() { BOOST_THREAD_LOG << boost::this_thread::get_id() << " <MAIN" << BOOST_THREAD_END_LOG; { try { boost::loop_executor tp; submit_some(tp); tp.run_queued_closures(); submit_some(tp); tp.run_queued_closures(); } catch (std::exception& ex) { BOOST_THREAD_LOG << "ERRORRRRR " << ex.what() << "" << BOOST_THREAD_END_LOG; return 1; } catch (...) { BOOST_THREAD_LOG << " ERRORRRRR exception thrown" << BOOST_THREAD_END_LOG; return 2; } } BOOST_THREAD_LOG << boost::this_thread::get_id() << "MAIN>" << BOOST_THREAD_END_LOG; return 0; }
int test_executor_adaptor() { // std::cout << BOOST_CONTEXTOF << std::endl; { try { #if ! defined(BOOST_NO_CXX11_RVALUE_REFERENCES) // std::cout << BOOST_CONTEXTOF << std::endl; { boost::basic_thread_pool ea1(4); boost::serial_executor_cont ea2(ea1); submit_some(ea2); boost::this_thread::sleep_for(boost::chrono::seconds(10)); } #endif // std::cout << BOOST_CONTEXTOF << 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; }
int main() { BOOST_THREAD_LOG << boost::this_thread::get_id() << " <MAIN" << BOOST_THREAD_END_LOG; { try { boost::basic_thread_pool tp; submit_some(tp); } catch (std::exception& ex) { BOOST_THREAD_LOG << "ERRORRRRR " << ex.what() << "" << BOOST_THREAD_END_LOG; return 1; } catch (...) { BOOST_THREAD_LOG << " ERRORRRRR exception thrown" << BOOST_THREAD_END_LOG; return 2; } } BOOST_THREAD_LOG << boost::this_thread::get_id() << "MAIN>" << BOOST_THREAD_END_LOG; return 0; }
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; }