24#include <seastar/util/modules.hh>
30#if defined(__x86_64__) || defined(__i386__)
38#if defined(__x86_64__) || defined(__i386__)
46inline void cpu_relax() {
53inline void cpu_relax() {
54 __asm__
volatile(
"yield");
57#elif defined(__s390x__) || defined(__zarch__)
61inline void cpu_relax() {}
63#elif defined(__aarch64__)
66inline void cpu_relax() {
67 __asm__
volatile(
"yield");
73inline void cpu_relax() {}
74#warning "Using an empty cpu_relax() for this architecture"
89 std::atomic<bool> _busy = {
false };
93 ~spinlock() { assert(!_busy.load(std::memory_order_relaxed)); }
94 bool try_lock()
noexcept {
95 return !_busy.exchange(
true, std::memory_order_acquire);
97 void lock()
noexcept {
98 while (_busy.exchange(
true, std::memory_order_acquire)) {
99 while (_busy.load(std::memory_order_relaxed)) {
100 internal::cpu_relax();
104 void unlock()
noexcept {
105 _busy.store(
false, std::memory_order_release);
Definition: spinlock.hh:88
Seastar API namespace.
Definition: abort_on_ebadf.hh:26