From 2465f88e783e4d704b0363e8544558eb65755ec8 Mon Sep 17 00:00:00 2001 From: azw Date: Sat, 13 May 2023 11:58:42 +0000 Subject: [PATCH] 1 --- a8/spinlock.cc | 6 +++--- a8/spinlock.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/a8/spinlock.cc b/a8/spinlock.cc index 4ffb55e..7d203fa 100644 --- a/a8/spinlock.cc +++ b/a8/spinlock.cc @@ -14,15 +14,15 @@ namespace a8 } - SpinLock::lock() + void SpinLock::lock() { 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); } diff --git a/a8/spinlock.h b/a8/spinlock.h index f8ab2b2..30b028a 100644 --- a/a8/spinlock.h +++ b/a8/spinlock.h @@ -17,7 +17,7 @@ namespace a8 private: - std::atomic flags_; + std::atomic flag_; };