ROOT
master
Reference Guide
Loading...
Searching...
No Matches
TAtomicCount.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_TAtomicCount
13
#define ROOT_TAtomicCount
14
15
16
//////////////////////////////////////////////////////////////////////////
17
// //
18
// TAtomicCount //
19
// //
20
// Class providing atomic operations on a long. Setting, getting, //
21
// incrementing and decrementing are atomic, thread safe, operations. //
22
// //
23
// TAtomicCount a(n); //
24
// //
25
// (n is convertible to long) //
26
// //
27
// Effects: Constructs an TAtomicCount with an initial value of n. //
28
// //
29
// long(a); //
30
// //
31
// Returns: (long) the current value of a. //
32
// //
33
// ++a; //
34
// //
35
// Effects: Atomically increments the value of a. //
36
// Returns: nothing. //
37
// //
38
// --a; //
39
// //
40
// Effects: Atomically decrements the value of a. //
41
// Returns: (long) zero if the new value of a is zero, //
42
// unspecified non-zero value otherwise //
43
// (usually the new value). //
44
// //
45
// a.Set(n); //
46
// //
47
// Effects: Set a to the value n. //
48
// Returns: nothing. //
49
// //
50
// a.Get(); //
51
// //
52
// Returns: (long) the current value of a. //
53
// //
54
// //
55
//////////////////////////////////////////////////////////////////////////
56
57
#include "
RtypesCore.h
"
58
#include "RConfigure.h"
59
60
#if (defined(__GLIBCPP__) || defined(__GLIBCXX__))
61
#include "
TAtomicCountGcc.h
"
62
#elif defined(_WIN32)
63
#include "
TWin32AtomicCount.h
"
64
#elif defined(R__HAS_PTHREAD)
65
#include "
TAtomicCountPthread.h
"
66
#else
67
class
TAtomicCount
{
68
private
:
69
Long_t
fCnt
;
// counter
70
71
TAtomicCount
(
const
TAtomicCount
&) =
delete
;
72
TAtomicCount
&
operator=
(
const
TAtomicCount
&) =
delete
;
73
74
public
:
75
explicit
TAtomicCount
(
Long_t
v
) :
fCnt
(
v
) { }
76
void
operator++
() { ++
fCnt
; }
77
Long_t
operator--
() {
return
--
fCnt
; }
78
operator
long()
const
{
return
fCnt
; }
79
void
Set
(
Long_t
v
) {
fCnt
=
v
; }
80
Long_t
Get
()
const
{
return
fCnt
; }
81
};
82
#endif
83
84
#endif
RtypesCore.h
Long_t
long Long_t
Definition
RtypesCore.h:54
TAtomicCountGcc.h
TAtomicCountPthread.h
TWin32AtomicCount.h
TAtomicCount
Definition
TAtomicCount.h:67
TAtomicCount::Get
Long_t Get() const
Definition
TAtomicCount.h:80
TAtomicCount::operator++
void operator++()
Definition
TAtomicCount.h:76
TAtomicCount::TAtomicCount
TAtomicCount(const TAtomicCount &)=delete
TAtomicCount::fCnt
Long_t fCnt
Definition
TAtomicCount.h:69
TAtomicCount::TAtomicCount
TAtomicCount(Long_t v)
Definition
TAtomicCount.h:75
TAtomicCount::operator--
Long_t operator--()
Definition
TAtomicCount.h:77
TAtomicCount::operator=
TAtomicCount & operator=(const TAtomicCount &)=delete
TAtomicCount::Set
void Set(Long_t v)
Definition
TAtomicCount.h:79
v
@ v
Definition
rootcling_impl.cxx:3699
core
thread
inc
TAtomicCount.h
ROOT master - Reference Guide Generated on Thu Dec 19 2024 09:45:33 (GVA Time) using Doxygen 1.9.8