Skip to content

Commit

Permalink
Speed improvement: Moving check online to different thread
Browse files Browse the repository at this point in the history
  • Loading branch information
tobbi authored and Tobias Markus committed Jan 24, 2014
1 parent c404b21 commit 74417aa
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/supertux/menu/addon_menu.cpp
Expand Up @@ -18,6 +18,7 @@

#include <config.h>
#include <algorithm>
#include <thread>
#include <boost/format.hpp>

#include "addon/addon.hpp"
Expand All @@ -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() :
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 74417aa

Please sign in to comment.