ROOT
master
Reference Guide
Loading...
Searching...
No Matches
TWin32AtomicCount.h
Go to the documentation of this file.
1
// @(#)root/thread:$Id$
2
// Author: Fons Rademakers 14/11/06
3
4
/*************************************************************************
5
* Copyright (C) 1995-2006, 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_TWin32AtomicCount
13
#define ROOT_TWin32AtomicCount
14
15
//////////////////////////////////////////////////////////////////////////
16
// //
17
// TWin32AtomicCount //
18
// //
19
// Class providing atomic operations on a long. Setting, getting, //
20
// incrementing and decrementing are atomic, thread safe, operations. //
21
// //
22
// This implementation uses the Win32 InterLocked API for locking. //
23
// //
24
//////////////////////////////////////////////////////////////////////////
25
26
#ifndef ROOT_TAtomicCount
27
#error "Do not use TWin32AtomicCount.h directly. #include \"TAtomicCount.h\" instead."
28
#endif
// ROOT_TAtomicCount
29
30
# include "
Windows4Root.h
"
31
32
class
TAtomicCount
{
33
private
:
34
Long_t
fCnt
;
// counter
35
36
TAtomicCount
(
const
TAtomicCount
&) =
delete
;
37
TAtomicCount
&
operator=
(
const
TAtomicCount
&) =
delete
;
38
39
public
:
40
explicit
TAtomicCount
(
Long_t
v
) :
fCnt
(
v
) { }
41
void
operator++
() {
_InterlockedIncrement
(&
fCnt
); }
42
Long_t
operator--
() {
return
_InterlockedDecrement
(&
fCnt
); }
43
operator
long()
const
{
return
static_cast<
long
const
volatile
&
>
(
fCnt
); }
44
void
Set
(
Long_t
v
) {
fCnt
=
v
; }
45
Long_t
Get
()
const
{
return
static_cast<
long
const
volatile
&
>
(
fCnt
); }
46
};
47
48
#endif
Long_t
long Long_t
Definition
RtypesCore.h:54
TRangeDynCast
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Definition
TCollection.h:358
Windows4Root.h
TAtomicCount
Definition
TAtomicCount.h:67
TAtomicCount::Get
Long_t Get() const
Definition
TWin32AtomicCount.h:45
TAtomicCount::operator++
void operator++()
Definition
TWin32AtomicCount.h:41
TAtomicCount::TAtomicCount
TAtomicCount(const TAtomicCount &)=delete
TAtomicCount::fCnt
Long_t fCnt
Definition
TAtomicCount.h:69
TAtomicCount::TAtomicCount
TAtomicCount(Long_t v)
Definition
TWin32AtomicCount.h:40
TAtomicCount::operator--
Long_t operator--()
Definition
TWin32AtomicCount.h:42
TAtomicCount::operator=
TAtomicCount & operator=(const TAtomicCount &)=delete
TAtomicCount::Set
void Set(Long_t v)
Definition
TWin32AtomicCount.h:44
v
@ v
Definition
rootcling_impl.cxx:3699
core
thread
inc
TWin32AtomicCount.h
ROOT master - Reference Guide Generated on Sun Apr 27 2025 05:49:48 (GVA Time) using Doxygen 1.10.0