Added spinlock based on std::atomic.