mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Replace CEF thread locking with C++11 locking
This removes the CEF dependency from LootState.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user