]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/seastar/include/seastar/util/spinlock.hh
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / seastar / include / seastar / util / spinlock.hh
index 162ec65e6d5794d9b0c42a7db267401ed7ac22bf..12774e6501ed5b159cc7b34c99734c6f23dd7405 100644 (file)
@@ -22,6 +22,7 @@
 #pragma once
 
 #include <atomic>
+#include <cassert>
 
 #if defined(__x86_64__) || defined(__i386__)
 #include <xmmintrin.h>
@@ -85,6 +86,9 @@ public:
     spinlock() = default;
     spinlock(const spinlock&) = delete;
     ~spinlock() { assert(!_busy.load(std::memory_order_relaxed)); }
+    bool try_lock() noexcept {
+        return !_busy.exchange(true, std::memory_order_acquire);
+    }
     void lock() noexcept {
         while (_busy.exchange(true, std::memory_order_acquire)) {
             internal::cpu_relax();