Kagome
Polkadot Runtime Engine in C++17
spin_lock.hpp
Go to the documentation of this file.
1 
6 #ifndef KAGOME_SPIN_LOCK_HPP
7 #define KAGOME_SPIN_LOCK_HPP
8 
9 #include <atomic>
10 
11 namespace kagome::common {
12 
32  class spin_lock { // the name styling is unified with std
33  public:
34  spin_lock() = default;
35  spin_lock(const spin_lock &) = delete;
36  spin_lock(spin_lock &&) = delete;
37  spin_lock &operator=(const spin_lock &) = delete;
38  spin_lock &operator=(spin_lock &&) = delete;
39 
46  void lock();
47 
51  void unlock();
52 
53  private:
54  std::atomic_flag flag_ = ATOMIC_FLAG_INIT;
55  };
56 
57 } // namespace kagome::common
58 
59 #endif // KAGOME_SPIN_LOCK_HPP
std::atomic_flag flag_
Definition: spin_lock.hpp:54
spin_lock & operator=(const spin_lock &)=delete