title: C++11 Implementation of Spinlock using header `<atomic>`
body: <p>I implemented SpinLock class, as followed</p>
  
  <pre><code>struct Node {
      int number;
      std::atomic_bool latch;
  
      void add() {
          lock();
          number++;
          unlock();
      }
      void lock() {
          bool unlatched = false;
          while(!latch.compare_exchange_weak(unlatched, true, std::memory_order_acquire));
      }
      void unlock() {
          latch.store(false , std::memory_order_release);
      }
  };
  </code></pre>
  
  <p>I implemented above class and made two threads which call add() method of a same instance of Node class 10 million times per thread. </p>
  
  <p>the result is , unfortunately, not 20 million.
  What am I missing here? </p>