From 6161ca8d59f29ef5b6b5cdb8c1286e5fcbaf2b4a Mon Sep 17 00:00:00 2001 From: EntireTwix Date: Wed, 23 Jun 2021 18:51:10 -0700 Subject: [PATCH] simplified changes saved --- include/bank.h | 19 +++++-------------- include/consts.hpp | 6 +++--- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/include/bank.h b/include/bank.h index 0e11db9..9f28efb 100644 --- a/include/bank.h +++ b/include/bank.h @@ -19,22 +19,9 @@ private: std::mutex> users; -#if CONSERVATIVE_DISK_SAVE std::atomic change_flag = false; //if true changes have been made - void ChangesMade() noexcept; //called after making changes - void ChangesSaved() noexcept; //called after saving - bool GetChangeState() noexcept; - -#define CHANGES_MADE ChangesMade(); -#define CHANGES_SAVED ChangesSaved(); -#define GET_CHANGE_STATE -#else -#define CHANGES_MADE -#define CHANGES_SAVED -#define GET_CHANGE_STATE -#endif - +private: /** * @brief size_l should be grabbed if the operation MODIFIES the size (shared), this is so that when save claims unique * @@ -50,6 +37,10 @@ private: public: std::string admin_pass; + void ChangesMade() noexcept; //called after making changes + void ChangesSaved() noexcept; //called after saving + bool GetChangeState() noexcept; + int_fast8_t AddUser(const std::string &name, const std::string &init_pass) noexcept; int_fast8_t AdminAddUser(const std::string &attempt, std::string &&name, uint32_t init_bal, std::string &&init_pass) noexcept; diff --git a/include/consts.hpp b/include/consts.hpp index 243ed8e..c8991d0 100644 --- a/include/consts.hpp +++ b/include/consts.hpp @@ -1,6 +1,6 @@ #pragma once -// Setting both values to 0 does not compile logging +// Setting both values to 0 does not compile logging (useful for if disk/memory is very valuable) constexpr unsigned max_log_size = 100; constexpr unsigned pre_log_size = 10; @@ -9,7 +9,7 @@ constexpr unsigned max_name_size = 50; constexpr const char *users_location = "../users.json"; constexpr const char *config_location = "../config.json"; -//returns money to an account on deletion +//returns money to an account on deletion (useful if you dont want any money to leave the economy) constexpr bool return_on_del = false; constexpr const char *return_account = ""; @@ -26,4 +26,4 @@ if false, when frequency is hit save cons CONSTANT disk usage */ -#define CONSERVATIVE_DISK_SAVE true \ No newline at end of file +#define CONSERVATIVE_DISK_SAVE true //TURN THIS OFF IF YOU THINK WITHIN YOUR SAVE FREQUENCY OF X MINUTES ITS GUARANTEED A CHANGE WILL OCCUR (typically massive servers) \ No newline at end of file