From 33d74d0ab51ada310921c11fb145b297ea34bb21 Mon Sep 17 00:00:00 2001 From: Oliver Hamlet Date: Sun, 10 Jan 2016 19:27:11 +0000 Subject: [PATCH] Replace CEF thread locking with C++11 locking This removes the CEF dependency from LootState. --- src/gui/loot_state.cpp | 13 +++++++------ src/gui/loot_state.h | 10 +++------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/gui/loot_state.cpp b/src/gui/loot_state.cpp index 9fcbd5ea..d2ac57fa 100644 --- a/src/gui/loot_state.cpp +++ b/src/gui/loot_state.cpp @@ -39,6 +39,10 @@ #include #include +#ifdef _WIN32 +#include +#endif + using namespace std; using boost::locale::translate; using boost::format; @@ -156,8 +160,7 @@ namespace loot { } void LootState::UpdateGamesFromSettings() { - // Acquire the lock for the scope of this method. - base::AutoLock lock_scope(_lock); + std::lock_guard guard(mutex); unordered_set newGameFolders; @@ -201,8 +204,7 @@ namespace loot { } void LootState::ChangeGame(const std::string& newGameFolder) { - // Acquire the lock for the scope of this method. - base::AutoLock lock_scope(_lock); + std::lock_guard guard(mutex); BOOST_LOG_TRIVIAL(debug) << "Changing current game to that with folder: " << newGameFolder; _currentGame = find(_games.begin(), _games.end(), Game(Game::autodetect, newGameFolder)); @@ -214,8 +216,7 @@ namespace loot { } Game& LootState::CurrentGame() { - // Acquire the lock for the scope of this method. - base::AutoLock lock_scope(_lock); + std::lock_guard guard(mutex); return *_currentGame; } diff --git a/src/gui/loot_state.h b/src/gui/loot_state.h index 26205135..b43242ca 100644 --- a/src/gui/loot_state.h +++ b/src/gui/loot_state.h @@ -28,11 +28,8 @@ #include "loot_settings.h" #include "backend/game/game.h" -#include -#include - namespace loot { - class LootState : public CefBase, public LootSettings { + class LootState : public LootSettings { public: LootState(); @@ -65,9 +62,8 @@ namespace loot { static std::list ToGames(const std::vector& settings); static std::vector ToGameSettings(const std::list& games); - // Lock used to protect access to member variables. - base::Lock _lock; - IMPLEMENT_REFCOUNTING(LootState); + // Mutex used to protect access to member variables. + std::mutex mutex; }; }