Implementing a spinlock in Boost. Example Needed
问题 I wanted to know if boost has any libraries that assist in implementing spin locks. I know boost supports mutexes but I could not find any examples that show or describe spinlocks in boost.Any examples showing how to implement a spin lock using boost(preferably) would be appreciated.(C++98) 回答1: Example using Boost.Atomic: #include <boost/atomic.hpp> class SpinLock { boost::atomic_flag flag; // it differs from std::atomic_flag a bit - // does not require ATOMIC_FLAG_INIT public: void lock() {