libtasks Documentation
1.6
Main Page
Namespaces
Classes
Files
File List
File Members
spinlock.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2013-2014 ADTECH GmbH
3
* Licensed under MIT (https://github.com/adtechlabs/libtasks/blob/master/COPYING)
4
*
5
* Author: Andreas Pohl
6
*/
7
8
#ifndef _SPINLOCK_H_
9
#define _SPINLOCK_H_
10
11
#include <atomic>
12
13
namespace
tasks {
14
namespace
tools {
15
16
class
spinlock
{
17
public
:
18
spinlock
() :
m_lock
(false) {}
19
20
inline
void
lock
() {
21
while
(
m_lock
.exchange(
true
)) {
22
}
23
}
24
25
inline
void
unlock
() {
m_lock
=
false
; }
26
27
private
:
28
std::atomic<bool>
m_lock
;
29
};
30
31
}
// tools
32
}
// tasks
33
34
#endif // _SPINLOCK_H_
tasks::tools::spinlock
Definition:
spinlock.h:16
tasks::tools::spinlock::m_lock
std::atomic< bool > m_lock
Definition:
spinlock.h:28
tasks::tools::spinlock::spinlock
spinlock()
Definition:
spinlock.h:18
tasks::tools::spinlock::unlock
void unlock()
Definition:
spinlock.h:25
tasks::tools::spinlock::lock
void lock()
Definition:
spinlock.h:20
include
tasks
tools
spinlock.h
Generated by
1.8.6