31namespace qb::lockfree {
81 return _lock.load(std::memory_order_acquire);
94 return !_lock.exchange(
true, std::memory_order_acquire);
112 }
while (spin-- > 0);
165 while (_lock.exchange(
true, std::memory_order_acquire))
176 _lock.store(
false, std::memory_order_release);
180 std::atomic<bool> _lock;
bool trylock() noexcept
Try to acquire the lock without spinning.
Definition spinlock.h:93
void lock() noexcept
Acquire the lock, waiting indefinitely if necessary.
Definition spinlock.h:164
SpinLock & operator=(const SpinLock &)=delete
Copy assignment operator is deleted to prevent copying of locks.
SpinLock() noexcept
Default constructor that initializes the lock to unlocked state.
Definition spinlock.h:46
SpinLock(SpinLock &&)=delete
Move constructor is deleted to prevent moving of locks.
bool trylock(int64_t spin) noexcept
Try to acquire the lock with a maximum number of spin attempts.
Definition spinlock.h:107
bool trylock_for(const Timespan ×pan) noexcept
Try to acquire the lock for a specified time duration.
Definition spinlock.h:128
SpinLock & operator=(SpinLock &&)=delete
Move assignment operator is deleted to prevent moving of locks.
void unlock() noexcept
Release the lock.
Definition spinlock.h:175
SpinLock(const SpinLock &)=delete
Copy constructor is deleted to prevent copying of locks.
~SpinLock()=default
Default destructor.
bool locked() noexcept
Check if the spinlock is currently locked.
Definition spinlock.h:80
bool trylock_until(const UtcTimestamp ×tamp) noexcept
Try to acquire the lock until a specified point in time.
Definition spinlock.h:152
TimePoint Timestamp
Backward compatibility alias for TimePoint.
Definition timestamp.h:1100
UtcTimePoint UtcTimestamp
Backward compatibility alias for UtcTimePoint.
Definition timestamp.h:1273
HighResTimePoint NanoTimestamp
Backward compatibility alias for HighResTimePoint.
Definition timestamp.h:1289
Duration Timespan
Backward compatibility alias for Duration.
Definition timestamp.h:1092
High-precision timing utilities.