ROOT
master
Reference Guide
Loading...
Searching...
No Matches
TSpinLockGuard.h
Go to the documentation of this file.
1
// @(#)root/meta:$Id$
2
// Author: Rene Brun 07/01/95
3
4
/*************************************************************************
5
* Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6
* All rights reserved. *
7
* *
8
* For the licensing terms see $ROOTSYS/LICENSE. *
9
* For the list of contributors see $ROOTSYS/README/CREDITS. *
10
*************************************************************************/
11
12
#ifndef ROOT_TSpinLockGuard
13
#define ROOT_TSpinLockGuard
14
15
#include <atomic>
16
17
namespace
ROOT
{
18
namespace
Internal
{
19
20
/**
21
* \class ROOT::Internal::TSpinLockGuard
22
* \brief A spin mutex-as-code-guard class.
23
* \ingroup Parallelism
24
* This class allows to acquire spin locks in combination with a std::atomic_flag variable.
25
* For example:
26
* ~~~{.cpp}
27
* mutable std::atomic_flag fSpinLock;
28
* [...]
29
* ROOT::Internal::TSpinLockGuard slg(fSpinLock);
30
* // do something important
31
* [...]
32
* ~~~{.cpp}
33
*/
34
35
class
TSpinLockGuard
{
36
// Trivial spin lock guard
37
public
:
38
TSpinLockGuard
(std::atomic_flag&
aflag
) :
fAFlag
(
aflag
)
39
{
40
while
(
fAFlag
.test_and_set(std::memory_order_acquire));
41
}
42
~TSpinLockGuard
() {
43
fAFlag
.clear(std::memory_order_release);
44
}
45
46
private
:
47
std::atomic_flag&
fAFlag
;
48
};
49
50
}
// namespace Internal
51
}
// namespace ROOT
52
53
#endif
// ROOT_TSpinLockGuard
ROOT::Detail::TRangeCast
Definition
TCollection.h:311
ROOT::Internal::TSpinLockGuard
A spin mutex-as-code-guard class.
Definition
TSpinLockGuard.h:35
ROOT::Internal::TSpinLockGuard::TSpinLockGuard
TSpinLockGuard(std::atomic_flag &aflag)
Definition
TSpinLockGuard.h:38
ROOT::Internal::TSpinLockGuard::fAFlag
std::atomic_flag & fAFlag
Definition
TSpinLockGuard.h:47
ROOT::Internal::TSpinLockGuard::~TSpinLockGuard
~TSpinLockGuard()
Definition
TSpinLockGuard.h:42
ROOT::Minuit2::GradientParameterSpace::Internal
@ Internal
ROOT
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
Definition
EExecutionPolicy.hxx:4
core
foundation
res
TSpinLockGuard.h
ROOT master - Reference Guide Generated on Fri Mar 21 2025 16:59:04 (GVA Time) using Doxygen 1.10.0