From: Tobias Markus Date: Sun, 15 Dec 2013 20:24:37 +0000 (+0100) Subject: Speed improvement: Moving check online to different thread X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=6d4d72e1670b7661049efdb378056b3a4333b467;p=supertux.git Speed improvement: Moving check online to different thread --- diff --git a/src/supertux/menu/addon_menu.cpp b/src/supertux/menu/addon_menu.cpp index a3cc6d5fa..e6ba6c577 100644 --- a/src/supertux/menu/addon_menu.cpp +++ b/src/supertux/menu/addon_menu.cpp @@ -18,6 +18,7 @@ #include #include +#include #include #include "addon/addon.hpp" @@ -31,6 +32,12 @@ bool generate_addons_menu_sorter(const Addon* a1, const Addon* a2) return a1->title < a2->title; } +void check_online() // Shortcut to expensive function to be called by a thread +{ + AddonManager::get_instance().check_online(); +} + + } // namespace AddonMenu::AddonMenu() : @@ -132,7 +139,8 @@ AddonMenu::check_menu() { try { - AddonManager::get_instance().check_online(); + std::thread addonThread(check_online); + addonThread.join(); refresh(); set_active_item(index); }