LSLab
include
lslab
mutex.h
Go to the documentation of this file.
1
4
#include "
lslab.h
"
5
#include <atomic>
6
#include <cuda/atomic>
7
8
#pragma once
9
10
namespace
lslab {
11
12
struct
mutex
{
13
14
mutex
() : l(0) {}
15
16
LSLAB_DEVICE
void
lock() {
17
int
expect = 0;
18
while
(!l.compare_exchange_strong(expect,-1)) {
19
expect = 0;
20
}
21
}
22
23
LSLAB_DEVICE
void
unlock() {
24
l.store(0);
25
}
26
27
union
{
28
alignas
(32)
char
_[32];
29
cuda::std::atomic<int> l;
30
};
31
};
32
33
}
lslab.h
lslab::mutex
Definition:
mutex.h:12
Generated by
1.9.1