30    SpinLock() { 
new(buffer) std::atomic<bool>(
false);  }
 
   37    ~SpinLock() { assert(!get().load());  get().~atomic<
bool>();  }
 
   40    void lock() { 
while (get().exchange(
true)) { } };
 
   43    void unlock() { get().store(
false);  } 
 
   45    bool try_lock() { 
return !get().exchange(
true);  } 
 
   48    std::atomic<bool> &get() { 
return *
reinterpret_cast<std::atomic<bool> *
>(buffer);  }
 
   50    char buffer[
sizeof(std::atomic<bool>)];
 
 
   68    ConditionalLock(T &t, 
bool use) : lock_(&t), use_(use) { 
if (use_) t.lock();  }
 
   69    ConditionalLock(T *t, 
bool use) : lock_(t), use_(use) { 
if (use_&&t) t->lock(); }
 
 
   88void atomicMax(std::atomic<T> &maxValue, T 
const &value) 
noexcept {
 
   89    T pvalue = maxValue.load();
 
   90    while (pvalue < value and not maxValue.compare_exchange_weak(pvalue, value)) { }
 
   95void atomicMin(std::atomic<T> &minValue, T 
const &value) 
noexcept {
 
   96    T pvalue = minValue.load();
 
   97    while (pvalue > value and not minValue.compare_exchange_weak(pvalue, value)) { }
 
  104    using std::atomic<T>::atomic;
 
  106    Atomic(
const std::atomic<T> &a) : std::atomic<T>(a.load()) { }
 
  108    Atomic &operator=(
const Atomic &a) { std::atomic<T>::store(a.load());  
return *
this; }
 
 
Base type definitions for the engine.
Definition spinlock.h:102
void unlock()
Release the lock.
Definition spinlock.h:43
void lock()
Acquire a lock using the test-and-set paradigm.
Definition spinlock.h:40
SpinLock()
By default the QAtomicInt is 0 on creation.
Definition spinlock.h:30
~SpinLock()
A SpinLock object can only be destroyed when it has been released.
Definition spinlock.h:37
#define BASE_EXPORT
Definition basedef.h:25