From 030d5d4a3ef5eab5213d071f89cf878c76c750e6 Mon Sep 17 00:00:00 2001 From: EntireTwix Date: Thu, 1 Apr 2021 21:24:29 -0700 Subject: [PATCH] :racehorse: removed thread safety locks as the phmap will handle thread safety --- include/user.hpp | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/include/user.hpp b/include/user.hpp index 1594dbf..15df8e6 100644 --- a/include/user.hpp +++ b/include/user.hpp @@ -8,10 +8,6 @@ private: uint_fast64_t balance; std::string password; - //for read/write of object's state concurrently - std::mutex bal_lock; - std::mutex pass_lock; - public: /** * @brief User constructor @@ -30,7 +26,6 @@ public: bool ChangePassword(const std::string &attempt, std::string &&new_pass) { - std::lock_guard lock{pass_lock}; const bool state = (password == attempt); if (state) { @@ -50,14 +45,7 @@ public: */ static bool SendFunds(User &a, User &b, uint_fast64_t amount, const std::string &attempt) { - bool state; - { - std::lock_guard lock{a.pass_lock}; - state = (a.password == attempt); - } - - std::scoped_lock lock{a.bal_lock, b.bal_lock}; - state = state && (a.balance >= amount); + const bool state = (a.password == attempt) && (a.balance >= amount); if (state) { a.balance -= amount;