Logo ROOT  
Reference Guide
MnReferenceCounter.h
Go to the documentation of this file.
1 // @(#)root/minuit2:$Id$
2 // Authors: M. Winkler, F. James, L. Moneta, A. Zsenei 2003-2005
3 
4 /**********************************************************************
5  * *
6  * Copyright (c) 2005 LCG ROOT Math team, CERN/PH-SFT *
7  * *
8  **********************************************************************/
9 
10 #ifndef ROOT_Minuit2_MnReferenceCounter
11 #define ROOT_Minuit2_MnReferenceCounter
12 
13 #include <cassert>
14 
15 #include "StackAllocator.h"
16 
17 namespace ROOT {
18 
19 namespace Minuit2 {
20 
21 // extern StackAllocator gStackAllocator;
22 
24 
25 public:
27 
29 
31  {
32  fReferences = other.fReferences;
33  return *this;
34  }
35 
36  ~MnReferenceCounter() { assert(fReferences == 0); }
37 
38  void *operator new(size_t nbytes) { return StackAllocatorHolder::Get().Allocate(nbytes); }
39 
40  void operator delete(void *p, size_t /*nbytes */) { StackAllocatorHolder::Get().Deallocate(p); }
41 
42  unsigned int References() const { return fReferences; }
43 
44  void AddReference() const { fReferences++; }
45 
46  void RemoveReference() const { fReferences--; }
47 
48 private:
49  mutable unsigned int fReferences;
50 };
51 
52 } // namespace Minuit2
53 
54 } // namespace ROOT
55 
56 #endif // ROOT_Minuit2_MnReferenceCounter
ROOT::Minuit2::MnReferenceCounter::operator=
MnReferenceCounter & operator=(const MnReferenceCounter &other)
Definition: MnReferenceCounter.h:30
ROOT::Minuit2::StackAllocator::Deallocate
void Deallocate(void *p)
Definition: StackAllocator.h:103
ROOT::Minuit2::MnReferenceCounter::RemoveReference
void RemoveReference() const
Definition: MnReferenceCounter.h:46
ROOT::Minuit2::MnReferenceCounter::MnReferenceCounter
MnReferenceCounter(const MnReferenceCounter &other)
Definition: MnReferenceCounter.h:28
ROOT::Minuit2::MnReferenceCounter::MnReferenceCounter
MnReferenceCounter()
Definition: MnReferenceCounter.h:26
StackAllocator.h
ROOT::Minuit2::StackAllocator::Allocate
void * Allocate(size_t nBytes)
Definition: StackAllocator.h:71
ROOT::Minuit2::MnReferenceCounter::fReferences
unsigned int fReferences
Definition: MnReferenceCounter.h:49
ROOT::Minuit2::StackAllocatorHolder::Get
static StackAllocator & Get()
Definition: StackAllocator.h:223
ROOT::Minuit2::MnReferenceCounter::AddReference
void AddReference() const
Definition: MnReferenceCounter.h:44
ROOT::Minuit2::MnReferenceCounter
Definition: MnReferenceCounter.h:23
ROOT::Minuit2::MnReferenceCounter::References
unsigned int References() const
Definition: MnReferenceCounter.h:42
ROOT
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
Definition: EExecutionPolicy.hxx:4
ROOT::Minuit2::MnReferenceCounter::~MnReferenceCounter
~MnReferenceCounter()
Definition: MnReferenceCounter.h:36