Replace CEF thread locking with C++11 locking

This removes the CEF dependency from LootState.
This commit is contained in:
Oliver Hamlet
2016-01-12 10:58:55 +00:00
parent e2ee8f838c
commit 33d74d0ab5
2 changed files with 10 additions and 13 deletions
+7 -6
View File
@@ -39,6 +39,10 @@
#include <boost/log/utility/setup/common_attributes.hpp>
#include <boost/log/support/date_time.hpp>
#ifdef _WIN32
#include <windows.h>
#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<std::mutex> guard(mutex);
unordered_set<string> 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<std::mutex> 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<std::mutex> guard(mutex);
return *_currentGame;
}
+3 -7
View File
@@ -28,11 +28,8 @@
#include "loot_settings.h"
#include "backend/game/game.h"
#include <include/cef_app.h>
#include <include/base/cef_lock.h>
namespace loot {
class LootState : public CefBase, public LootSettings {
class LootState : public LootSettings {
public:
LootState();
@@ -65,9 +62,8 @@ namespace loot {
static std::list<Game> ToGames(const std::vector<GameSettings>& settings);
static std::vector<GameSettings> ToGameSettings(const std::list<Game>& 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;
};
}