SDRAngel
4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
sdrbase
util
spinlock.h
Go to the documentation of this file.
1
#ifndef INCLUDE_SPINLOCK_H
2
#define INCLUDE_SPINLOCK_H
3
4
#include <QAtomicInt>
5
6
#include "
export.h
"
7
8
class
SDRBASE_API
Spinlock
{
9
public
:
10
void
lock
()
11
{
12
while
(!m_atomic.testAndSetAcquire(0, 1)) ;
13
}
14
15
void
unlock
()
16
{
17
while
(!m_atomic.testAndSetRelease(1, 0)) ;
18
}
19
20
protected
:
21
QAtomicInt
m_atomic
;
22
};
23
24
class
SpinlockHolder
{
25
public
:
26
SpinlockHolder
(
Spinlock
* spinlock) :
27
m_spinlock(spinlock)
28
{
29
m_spinlock->lock();
30
}
31
32
~SpinlockHolder
()
33
{
34
m_spinlock->unlock();
35
}
36
37
protected
:
38
Spinlock
*
m_spinlock
;
39
};
40
41
#endif // INCLUDE_SPINLOCK_H
SpinlockHolder::~SpinlockHolder
~SpinlockHolder()
Definition:
spinlock.h:32
SpinlockHolder::SpinlockHolder
SpinlockHolder(Spinlock *spinlock)
Definition:
spinlock.h:26
Spinlock::lock
void lock()
Definition:
spinlock.h:10
Spinlock::unlock
void unlock()
Definition:
spinlock.h:15
export.h
Spinlock
Definition:
spinlock.h:8
SpinlockHolder
Definition:
spinlock.h:24
Spinlock::m_atomic
QAtomicInt m_atomic
Definition:
spinlock.h:21
SDRBASE_API
#define SDRBASE_API
Definition:
export.h:40
SpinlockHolder::m_spinlock
Spinlock * m_spinlock
Definition:
spinlock.h:38
Generated on Fri Aug 2 2019 17:56:33 for SDRAngel by
1.8.13