diff --git a/src/events.cpp b/src/events.cpp index 226ecace4ff9..2ccadce79867 100644 --- a/src/events.cpp +++ b/src/events.cpp @@ -31,11 +31,11 @@ #include #include #include +#include #include #include -#include #define ERR_GEN LOG_STREAM(err, lg::general) @@ -420,11 +420,11 @@ static bool remove_on_resize(const SDL_Event& a) } // TODO: I'm uncertain if this is always safe to call at static init; maybe set in main() instead? -static const boost::thread::id main_thread = boost::this_thread::get_id(); +static const std::thread::id main_thread = std::this_thread::get_id(); void pump() { - if(boost::this_thread::get_id() != main_thread) { + if(std::this_thread::get_id() != main_thread) { // Can only call this on the main thread! return; } @@ -756,7 +756,7 @@ void peek_for_resize() void call_in_main_thread(const std::function& f) { - if(boost::this_thread::get_id() == main_thread) { + if(std::this_thread::get_id() == main_thread) { // nothing special to do if called from the main thread. f(); return; diff --git a/src/gui/dialogs/loading_screen.cpp b/src/gui/dialogs/loading_screen.cpp index 4202a87f6072..60ea60562a20 100644 --- a/src/gui/dialogs/loading_screen.cpp +++ b/src/gui/dialogs/loading_screen.cpp @@ -32,8 +32,6 @@ #include "utils/functional.hpp" #include "video.hpp" -#include - #include #if defined(_MSC_VER) && _MSC_VER <= 1800 @@ -109,7 +107,7 @@ loading_screen::loading_screen(std::function f) void loading_screen::pre_show(window& window) { if(work_) { - worker_.reset(new boost::thread([this]() { + worker_.reset(new std::thread([this]() { is_worker_running_ = true; try { @@ -154,12 +152,13 @@ loading_screen* loading_screen::current_load = nullptr; void loading_screen::timer_callback(window& window) { - if(!work_ || !worker_ || worker_->timed_join(boost::posix_time::milliseconds(0))) { + if(!work_ || !worker_ || !is_worker_running_) { if(exception_) { clear_timer(); std::rethrow_exception(exception_); } + worker_->detach(); window.close(); } diff --git a/src/gui/dialogs/loading_screen.hpp b/src/gui/dialogs/loading_screen.hpp index c1ea099bbcd1..e53d9e713545 100644 --- a/src/gui/dialogs/loading_screen.hpp +++ b/src/gui/dialogs/loading_screen.hpp @@ -19,11 +19,8 @@ #include #include #include +#include -namespace boost -{ - class thread; -} namespace cursor { struct setter; @@ -86,7 +83,7 @@ class loading_screen : public modal_dialog std::size_t timer_id_; int animation_counter_; std::function work_; - std::unique_ptr worker_; + std::unique_ptr worker_; std::unique_ptr cursor_setter_; std::exception_ptr exception_; void clear_timer(); diff --git a/src/wesnothd_connection.cpp b/src/wesnothd_connection.cpp index dad8aca5b2f2..123df4368b51 100644 --- a/src/wesnothd_connection.cpp +++ b/src/wesnothd_connection.cpp @@ -22,8 +22,6 @@ #include -#include - #include #include @@ -83,6 +81,7 @@ wesnothd_connection::wesnothd_connection(const std::string& host, const std::str wesnothd_connection::~wesnothd_connection() { + worker_thread_->detach(); MPTEST_LOG; // Stop the io_service and wait for the worker thread to terminate. @@ -155,7 +154,7 @@ void wesnothd_connection::handle_handshake(const error_code& ec) handshake_finished_ = true; recv(); - worker_thread_.reset(new boost::thread([this]() { + worker_thread_.reset(new std::thread([this]() { io_service_.run(); LOG_NW << "wesnothd_connection::io_service::run() returned\n"; })); diff --git a/src/wesnothd_connection.hpp b/src/wesnothd_connection.hpp index 55f872d37609..880b5718650c 100644 --- a/src/wesnothd_connection.hpp +++ b/src/wesnothd_connection.hpp @@ -37,13 +37,9 @@ #include #include +#include #include -namespace boost -{ -class thread; -} - class config; enum class loading_stage; @@ -129,7 +125,7 @@ class wesnothd_connection } private: - std::unique_ptr worker_thread_; + std::unique_ptr worker_thread_; boost::asio::io_service io_service_;