session::~session() { aux::dump_call_profile(); TORRENT_ASSERT(m_impl); boost::shared_ptr<session_impl> ptr = m_impl; // capture the shared_ptr in the dispatched function // to keep the session_impl alive m_impl->get_io_service().dispatch([=]() { ptr->abort(); }); #if defined TORRENT_ASIO_DEBUGGING int counter = 0; while (log_async()) { std::this_thread::sleep_for(seconds(1)); ++counter; std::printf("\x1b[2J\x1b[0;0H\x1b[33m==== Waiting to shut down: %d ==== \x1b[0m\n\n" , counter); } async_dec_threads(); std::fprintf(stderr, "\n\nEXPECTS NO MORE ASYNC OPS\n\n\n"); #endif if (m_thread && m_thread.unique()) m_thread->join(); }
session::~session() { aux::dump_call_profile(); TORRENT_ASSERT(m_impl); TORRENT_ASYNC_CALL(abort); #if defined TORRENT_ASIO_DEBUGGING int counter = 0; while (log_async()) { sleep(1000); ++counter; printf("\x1b[2J\x1b[0;0H\x1b[33m==== Waiting to shut down: %d ==== \x1b[0m\n\n" , counter); } async_dec_threads(); fprintf(stderr, "\n\nEXPECTS NO MORE ASYNC OPS\n\n\n"); #endif if (m_thread && m_thread.unique()) m_thread->join(); }