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.
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 
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 
25 public:
26  SpinlockHolder(Spinlock* spinlock) :
27  m_spinlock(spinlock)
28  {
29  m_spinlock->lock();
30  }
31 
33  {
34  m_spinlock->unlock();
35  }
36 
37 protected:
39 };
40 
41 #endif // INCLUDE_SPINLOCK_H
SpinlockHolder(Spinlock *spinlock)
Definition: spinlock.h:26
void lock()
Definition: spinlock.h:10
void unlock()
Definition: spinlock.h:15
QAtomicInt m_atomic
Definition: spinlock.h:21
#define SDRBASE_API
Definition: export.h:40
Spinlock * m_spinlock
Definition: spinlock.h:38