Logo ROOT   6.08/07
Reference Guide
TAtomicCountWin32.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_TAtomicCountWin32
13 #define ROOT_TAtomicCountWin32
14 
15 //////////////////////////////////////////////////////////////////////////
16 // //
17 // TAtomicCountWin32 //
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 // ATTENTION: Don't use this file directly, it is included by //
25 // TAtomicCount.h. //
26 // //
27 //////////////////////////////////////////////////////////////////////////
28 
29 # include "Windows4Root.h"
30 
31 class TAtomicCount {
32 private:
33  Long_t fCnt; // counter
34 
35  TAtomicCount(const TAtomicCount &); // not implemented
36  TAtomicCount &operator=(const TAtomicCount &); // not implemented
37 
38 public:
39  explicit TAtomicCount(Long_t v) : fCnt(v) { }
40  void operator++() { InterlockedIncrement(&fCnt); }
41  Long_t operator--() { return InterlockedDecrement(&fCnt); }
42  operator long() const { return static_cast<long const volatile &>(fCnt); }
43  void Set(Long_t v) { fCnt = v; }
44  Long_t Get() const { return static_cast<long const volatile &>(fCnt); }
45 };
46 
47 #endif
Long_t operator--()
Long_t Get() const
SVector< double, 2 > v
Definition: Dict.h:5
void Set(Long_t v)
TAtomicCount(Long_t v)
long Long_t
Definition: RtypesCore.h:50
TAtomicCount & operator=(const TAtomicCount &)
TAtomicCount(const TAtomicCount &)