Project
Loading...
Searching...
No Matches
stdspinlock.h
Go to the documentation of this file.
1
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3
// All rights not expressly granted are reserved.
4
//
5
// This software is distributed under the terms of the GNU General Public
6
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7
//
8
// In applying this license CERN does not waive the privileges and immunities
9
// granted to it by virtue of its status as an Intergovernmental Organization
10
// or submit itself to any jurisdiction.
11
14
15
#ifndef Q_STDSPINLOCK_H
16
#define Q_STDSPINLOCK_H
17
18
#include <atomic>
19
20
class
stdspinlock
21
{
22
public
:
23
stdspinlock
(std::atomic_flag& flag) : mFlag(&flag)
24
{
25
while
(flag.test_and_set(std::memory_order_acquire)) {
26
}
27
}
28
void
release
()
29
{
30
if
(mFlag) {
31
mFlag->clear(std::memory_order_release);
32
mFlag =
nullptr
;
33
}
34
}
35
~stdspinlock
()
36
{
37
release
();
38
}
39
40
private
:
41
std::atomic_flag* mFlag;
42
};
43
44
#endif
// Q_STDSPINLOCK_H
stdspinlock
Definition
stdspinlock.h:21
stdspinlock::release
void release()
Definition
stdspinlock.h:28
stdspinlock::stdspinlock
stdspinlock(std::atomic_flag &flag)
Definition
stdspinlock.h:23
stdspinlock::~stdspinlock
~stdspinlock()
Definition
stdspinlock.h:35
GPU
GPUTracking
utils
stdspinlock.h
Generated on Sat Oct 18 2025 07:25:07 for Project by
1.9.8