mirror of
https://gitlab.com/Mr_Goldberg/goldberg_emulator.git
synced 2024-11-09 22:28:38 +01:00
Switch to atomic_bool for thread synchronisation.
This commit is contained in:
parent
5c66c21f53
commit
573a01212b
3 changed files with 7 additions and 5 deletions
|
@ -17,9 +17,9 @@
|
||||||
#include "item_db_loader.h"
|
#include "item_db_loader.h"
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include "json.hpp"
|
#include "../json/json.hpp"
|
||||||
|
|
||||||
void read_items_db(std::string items_db, std::map<SteamItemDef_t, std::map<std::string, std::string>> *items, bool *is_loadedb)
|
void read_items_db(std::string items_db, std::map<SteamItemDef_t, std::map<std::string, std::string>> *items, std::atomic_bool *is_loadedb)
|
||||||
{
|
{
|
||||||
std::ifstream items_file(items_db);
|
std::ifstream items_file(items_db);
|
||||||
// If there is a file and we opened it
|
// If there is a file and we opened it
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
#include "base.h" // For SteamItemDef_t
|
#include "base.h" // For SteamItemDef_t
|
||||||
|
|
||||||
void read_items_db(std::string items_db, std::map<SteamItemDef_t, std::map<std::string, std::string>> *items, bool *is_loaded);
|
#include <atomic>
|
||||||
|
void read_items_db(std::string items_db, std::map<SteamItemDef_t, std::map<std::string, std::string>> *items, std::atomic_bool *is_loaded);
|
||||||
|
|
||||||
#endif//__ITEM_DB_LOADER_INCLUDED__
|
#endif//__ITEM_DB_LOADER_INCLUDED__
|
|
@ -16,6 +16,7 @@
|
||||||
<http://www.gnu.org/licenses/>. */
|
<http://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
#include "item_db_loader.h"
|
#include "item_db_loader.h"
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
struct Steam_Inventory_Requests {
|
struct Steam_Inventory_Requests {
|
||||||
double timeout = 0.1;
|
double timeout = 0.1;
|
||||||
|
@ -57,7 +58,7 @@ class Steam_Inventory :
|
||||||
// Or find a server somewhere to hold the data for us then cache on local settings.
|
// Or find a server somewhere to hold the data for us then cache on local settings.
|
||||||
bool need_load_definitions = true;
|
bool need_load_definitions = true;
|
||||||
|
|
||||||
bool items_loaded = false;
|
std::atomic_bool items_loaded = false;
|
||||||
|
|
||||||
struct Steam_Inventory_Requests* new_inventory_result(const SteamItemInstanceID_t* pInstanceIDs = NULL, uint32 unCountInstanceIDs = 0)
|
struct Steam_Inventory_Requests* new_inventory_result(const SteamItemInstanceID_t* pInstanceIDs = NULL, uint32 unCountInstanceIDs = 0)
|
||||||
{
|
{
|
||||||
|
@ -90,7 +91,7 @@ public:
|
||||||
|
|
||||||
Steam_Inventory(class Settings *settings, class SteamCallResults *callback_results, class SteamCallBacks *callbacks)
|
Steam_Inventory(class Settings *settings, class SteamCallResults *callback_results, class SteamCallBacks *callbacks)
|
||||||
{
|
{
|
||||||
std::thread items_load_thread(read_items_db, Local_Storage::get_program_path() + PATH_SEPARATOR + "steam_items.json", &items, &items_loaded);
|
std::thread items_load_thread(read_items_db, Local_Storage::get_game_settings_path() + PATH_SEPARATOR + "items.json", &items, &items_loaded);
|
||||||
items_load_thread.detach();
|
items_load_thread.detach();
|
||||||
|
|
||||||
this->settings = settings;
|
this->settings = settings;
|
||||||
|
|
Loading…
Reference in a new issue