This commit is contained in:
azw 2023-05-13 11:58:42 +00:00
parent 35fab7672b
commit 2465f88e78
2 changed files with 4 additions and 4 deletions

View File

@ -14,15 +14,15 @@ namespace a8
} }
SpinLock::lock() void SpinLock::lock()
{ {
bool expect = false; bool expect = false;
while (!flag_.compare_exchange_weak(except, true)) { while (!flag_.compare_exchange_weak(expect, true)) {
} }
} }
SpinLock::unlock() void SpinLock::unlock()
{ {
flag_.store(false); flag_.store(false);
} }

View File

@ -17,7 +17,7 @@ namespace a8
private: private:
std::atomic<bool> flags_; std::atomic<bool> flag_;
}; };