Fleet  0.0.9
Inference in the LOT
SpinLock.h
Go to the documentation of this file.
1 #pragma once
2 
10 class SpinLock {
11  //https://stackoverflow.com/questions/26583433/c11-implementation-of-spinlock-using-atomic
12  std::atomic_flag locked = ATOMIC_FLAG_INIT;
13 public:
14  void lock() {
15  while (locked.test_and_set(std::memory_order_acquire)) { ; }
16  }
17  void unlock() {
18  locked.clear(std::memory_order_release);
19  }
20 };
21 
Definition: SpinLock.h:10
void lock()
Definition: SpinLock.h:14
void unlock()
Definition: SpinLock.h:17