/** Test out callstack functionality * * Currently broken on windows when running from dll * */ #include #include #include #include bool strand_dispatched = false; bool io_service_dispatched = false; void strand_handler2() { strand_dispatched = true; } void strand_handler(boost::asio::strand &strand) { if(strand.running_in_this_thread()) { std::cout << "running_in_this_thread: PASS\n"; } else { std::cout << "running_in_this_thread: FAIL\n"; } strand.dispatch(&strand_handler2); if(strand_dispatched) { std::cout << "strand dispatch: PASS\n"; } else { std::cout << "strand dispatch: FAIL\n"; } } void io_service_handler2() { io_service_dispatched = true; } void service_handler(boost::asio::io_service &io_service) { io_service.dispatch(&io_service_handler2); if(io_service_dispatched) { std::cout << "io_service dispatch: PASS\n"; } else { std::cout << "io_service dispatch: FAIL\n"; } } void wait_for_debugger() { std::string input; std::cout << "Attach debugger, and press CTRL-d \n"; std::cin >> input; } int main(int /*argc*/, char ** /*argv*/) { //wait_for_debugger(); boost::asio::io_service io_service; boost::asio::strand strand(io_service); strand.post(boost::bind(&strand_handler, boost::ref(strand))); io_service.post(boost::bind(&service_handler, boost::ref(io_service))); io_service.run(); return 0; }