File: AtomicInt.h

package info (click to toggle)
lmms 1.2.2%2Bdfsg1-6
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 55,184 kB
  • sloc: cpp: 159,844; ansic: 98,570; python: 2,555; sh: 551; makefile: 27; xml: 18
file content (45 lines) | stat: -rw-r--r-- 679 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/// \file  AtomicInt.h
/// \brief Compatibility subclass of QAtomicInt for supporting both Qt4 and Qt5

#ifndef LMMS_ATOMIC_H
#define LMMS_ATOMIC_H

#include <QtCore/QAtomicInt>

#if QT_VERSION < 0x050300

class AtomicInt : public QAtomicInt
{
public:
	AtomicInt( int value = 0 ) :
		QAtomicInt( value )
	{
	}

	int fetchAndAndOrdered( int valueToAnd )
	{
		int value;
		do
		{
			value = (int)*this;
		}
		while( !testAndSetOrdered( value, value & valueToAnd ) );
		return value;
	}

#if QT_VERSION >= 0x050000 && QT_VERSION < 0x050300
	operator int() const
	{
		return loadAcquire();
	}
#endif

};

#else

typedef QAtomicInt AtomicInt;

#endif // QT_VERSION < 0x050300

#endif