class cpp_test_spinlock {
	volatile bool lockBool = 0;

  public:
	inline void lock() {
		for ( ;; ) {
			if ( (this->lockBool == 0) && (__atomic_test_and_set( &this->lockBool, __ATOMIC_ACQUIRE ) == 0) ) break;
		}
	}

	inline bool try_lock() {
		return (this->lockBool == 0) && (__atomic_test_and_set( &this->lockBool, __ATOMIC_ACQUIRE ) == 0);
	}

	inline void unlock() {
		__atomic_clear( &this->lockBool, __ATOMIC_RELEASE );
	}
};