AtomicInt.h 679 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /// \file AtomicInt.h
  2. /// \brief Compatibility subclass of QAtomicInt for supporting both Qt4 and Qt5
  3. #ifndef LMMS_ATOMIC_H
  4. #define LMMS_ATOMIC_H
  5. #include <QtCore/QAtomicInt>
  6. #if QT_VERSION < 0x050300
  7. class AtomicInt : public QAtomicInt
  8. {
  9. public:
  10. AtomicInt( int value = 0 ) :
  11. QAtomicInt( value )
  12. {
  13. }
  14. int fetchAndAndOrdered( int valueToAnd )
  15. {
  16. int value;
  17. do
  18. {
  19. value = (int)*this;
  20. }
  21. while( !testAndSetOrdered( value, value & valueToAnd ) );
  22. return value;
  23. }
  24. #if QT_VERSION >= 0x050000 && QT_VERSION < 0x050300
  25. operator int() const
  26. {
  27. return loadAcquire();
  28. }
  29. #endif
  30. };
  31. #else
  32. typedef QAtomicInt AtomicInt;
  33. #endif // QT_VERSION < 0x050300
  34. #endif