🐎🚚 moved shared lock to decrease scope accurately

This commit is contained in:
EntireTwix 2021-07-13 16:31:39 -07:00
parent 0954a76b6a
commit a65224d39e

View file

@ -245,7 +245,6 @@ BankResponse Bank::AddUser(const std::string &name, uint32_t init_bal, std::stri
}
BankResponse Bank::DelUser(const std::string &name) noexcept
{
std::shared_lock<std::shared_mutex> lock{save_lock};
#if RETURN_ON_DEL
uint32_t bal;
if (users.if_contains(name, [&bal](const User &u) { bal = u.balance; }) && bal)
@ -256,6 +255,7 @@ BankResponse Bank::DelUser(const std::string &name) noexcept
}
}
#endif
std::shared_lock<std::shared_mutex> lock{save_lock};
if (users.erase(name))
{
#if CONSERVATIVE_DISK_SAVE