summaryrefslogtreecommitdiffstats
path: root/src/common/spin_lock.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/common/spin_lock.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/common/spin_lock.cpp b/src/common/spin_lock.cpp
index 8077b78d2..82a1d39ff 100644
--- a/src/common/spin_lock.cpp
+++ b/src/common/spin_lock.cpp
@@ -43,4 +43,11 @@ void SpinLock::unlock() {
lck.clear(std::memory_order_release);
}
+bool SpinLock::try_lock() {
+ if (lck.test_and_set(std::memory_order_acquire)) {
+ return false;
+ }
+ return true;
+}
+
} // namespace Common