ATLAS Offline Software
LWPools.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
7 // //
8 // Header file for class LWPools //
9 // //
10 // Description: ... //
11 // //
12 // Author: Thomas H. Kittelmann (Thomas.Kittelmann@cern.ch) //
13 // Initial version: May 2009 //
14 // //
16 
17 #ifndef LWPOOLS_H
18 #define LWPOOLS_H
19 
20 #include "LWPoolSelector.h"
21 #include "LWPool.h"
23 #include <cassert>
24 #include <atomic>
25 
26 #define MP_NEW(Class) new(LWPools::acquire(sizeof(Class))) Class
27 #define MP_DELETE(Ptr) LWPools::deleteObject(Ptr)
28 
29 class LWPools {
30 public:
31 
32  //The fundamental interface:
33  static char * acquire(unsigned length);
34  static void release(char*,unsigned length);
35  static void cleanup();//Returns all acquired memory to the system.
36  //Not safe to call this concurrently with anything
37  //else.
38 
39  //Convenience:
40  template<unsigned length> static char* acquire() { return acquire(length); }
41  template<unsigned length> static void release(char*c) { return release(c,length); }
42  template<class T, unsigned length> static T* acquire();
43  template<class T, unsigned length> static void release(T*);
44  template<class T> static T * acquire(unsigned length);
45  template<class T> static void release(T*,unsigned length);
46 
47  //For MP_DELETE (to ensure the destructor gets called):
48  template<class T> static void deleteObject(T*);
49 
50  //statistics:
51  static long long getTotalPoolMemAllocated();
52  static long long getTotalPoolMemUsed();
53 
54 private:
57 private:
58  class PoolList;
59  static PoolList s_pools ATLAS_THREAD_SAFE;
60  static std::atomic<long long> s_bytesDynAlloc;
61  static LWPool * initPool(unsigned poolIndex,unsigned length);
62  static LWPool * getPool(unsigned length);
63  LWPools( const LWPools & );
64  LWPools & operator= ( const LWPools & );
65 };
66 
67 #include "LWPools.icc"
68 
69 #endif
LWPools::getTotalPoolMemUsed
static long long getTotalPoolMemUsed()
Definition: LWPools.cxx:84
LWPoolSelector.h
LWPools::getTotalPoolMemAllocated
static long long getTotalPoolMemAllocated()
Definition: LWPools.cxx:78
LWPools
Definition: LWPools.h:29
LWPools::acquire
static T * acquire()
LWPools::release
static void release(char *, unsigned length)
LWPools::release
static void release(T *)
LWPools::release
static void release(char *c)
Definition: LWPools.h:41
LWPools::ATLAS_THREAD_SAFE
static PoolList s_pools ATLAS_THREAD_SAFE
Definition: LWPools.h:58
LWPools::~LWPools
~LWPools()
LWPools::release
static void release(T *, unsigned length)
LWPools::acquire
static char * acquire(unsigned length)
LWPools::LWPools
LWPools()
LWPools::acquire
static char * acquire()
Definition: LWPools.h:40
LWPools::operator=
LWPools & operator=(const LWPools &)
LWPools::s_bytesDynAlloc
static std::atomic< long long > s_bytesDynAlloc
Definition: LWPools.h:60
LWPools::acquire
static T * acquire(unsigned length)
LWPools::deleteObject
static void deleteObject(T *)
LWPools::LWPools
LWPools(const LWPools &)
LWPools::getPool
static LWPool * getPool(unsigned length)
LWPools.icc
LWPool
Definition: LWPool.h:24
checker_macros.h
Define macros for attributes used to control the static checker.
python.compressB64.c
def c
Definition: compressB64.py:93
length
double length(const pvec &v)
Definition: FPGATrackSimLLPDoubletHoughTransformTool.cxx:26
LWPools::cleanup
static void cleanup()
Definition: LWPools.cxx:71
LWPool.h
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35
LWPools::initPool
static LWPool * initPool(unsigned poolIndex, unsigned length)
Definition: LWPools.cxx:54