mirror of
https://github.com/Expand-sys/CCash
synced 2025-12-19 01:22:14 +11:00
🐛 got change flag working
This commit is contained in:
parent
2ea4d93c10
commit
992b8371d1
1 changed files with 6 additions and 12 deletions
16
src/bank.cpp
16
src/bank.cpp
|
|
@ -3,34 +3,28 @@
|
||||||
#if CONSERVATIVE_DISK_SAVE
|
#if CONSERVATIVE_DISK_SAVE
|
||||||
void Bank::ChangesMade() noexcept
|
void Bank::ChangesMade() noexcept
|
||||||
{
|
{
|
||||||
return change_flag.test_and_set();
|
return change_flag.store(1, std::memory_order_release);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bank::ChangesSaved() noexcept
|
void Bank::ChangesSaved() noexcept
|
||||||
{
|
{
|
||||||
return change_flag.clear();
|
return change_flag.store(1, std::memory_order_release);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Bank::GetChangeState() noexcept
|
bool Bank::GetChangeState() noexcept
|
||||||
{
|
{
|
||||||
return change_flag.test();
|
return change_flag.load(std::memory_order_acquire);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int_fast8_t Bank::AddUser(const std::string &name, const std::string &init_pass) noexcept
|
int_fast8_t Bank::AddUser(const std::string &name, const std::string &init_pass) noexcept
|
||||||
{
|
{
|
||||||
if (name.size() > max_name _size)
|
if (name.size() > max_name_size)
|
||||||
{
|
{
|
||||||
return ErrorResponse::NameTooLong;
|
return ErrorResponse::NameTooLong;
|
||||||
}
|
}
|
||||||
//replace with string find
|
if (name.find(' ') != std::string::npos)
|
||||||
for (char c : name)
|
|
||||||
{
|
|
||||||
if (c == ' ')
|
|
||||||
{
|
{
|
||||||
return ErrorResponse::InvalidRequest;
|
return ErrorResponse::InvalidRequest;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
{
|
{
|
||||||
std::shared_lock<std::shared_mutex> lock{size_l};
|
std::shared_lock<std::shared_mutex> lock{size_l};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue