ATLAS Offline Software
LWPoolArea.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
7 // //
8 // Header file for class LWPoolArea //
9 // //
10 // Description: ... //
11 // //
12 // Author: Thomas H. Kittelmann (Thomas.Kittelmann@cern.ch) //
13 // Initial version: April 2009 //
14 // //
16 
17 #ifndef LWPOOLAREA_H
18 #define LWPOOLAREA_H
19 
20 #include "LWPoolAreaBookKeeper.h"
21 #include <climits>//UINT_MAX
22 #include <new>//placement new
23 #include <cassert>
24 
25 class LWPoolArea {
26 public:
27 
28  //Create an LWPoolArea at a given address (mem will include the
29  //class itself, bytes for book-keeping and finally the actual pool
30  //area:
31  static LWPoolArea* create( unsigned chunksize,
32  char* mem,
33  unsigned length_of_mem,
34  unsigned nchunks = UINT_MAX );
35  //If nchunks==UINT_MAX, a few calculations will be performed, to fit
36  //as many chunks into length_of_mem as possible (non-trivial due to
37  //variable length of book-keeping bytes). If you already have at
38  //least one area with the same (chunksize,length_of_mem), simply ask
39  //it for the nchunks and pass here.
40 
41  char* acquire();
42  void release(char*c);
43  bool isUnused() const;
44 
45  long long getMemDishedOut() const;
46  //For debug build only:
47 #ifndef NDEBUG
48  long long getMemUnusedButAllocated() const;
49  bool belongsInArea(char*c) const;//only in debug mode!
50 #endif
51 
52  unsigned totalNumberOfChunks() const { return m_nchunks; }
53 private:
54 
55  LWPoolArea( const LWPoolArea & );
57 
58  //class Imp;
59  LWPoolArea(unsigned chunksize,unsigned nchunks);
60  ~LWPoolArea(){}//Not needed - can simply release
61  const unsigned m_chunksize;
62  const unsigned m_nchunks;
64  char * m_area;
65  static unsigned calcNChunks(unsigned chunksize,unsigned length_of_mem);
66 };
67 
68 #include "LWPoolArea.icc"
69 
70 #endif
LWPoolArea::create
static LWPoolArea * create(unsigned chunksize, char *mem, unsigned length_of_mem, unsigned nchunks=UINT_MAX)
LWPoolArea.icc
LWPoolArea::belongsInArea
bool belongsInArea(char *c) const
LWPoolArea::operator=
LWPoolArea & operator=(const LWPoolArea &)
LWPoolArea::m_chunksize
const unsigned m_chunksize
Definition: LWPoolArea.h:61
LWPoolArea::getMemUnusedButAllocated
long long getMemUnusedButAllocated() const
LWPoolArea::release
void release(char *c)
LWPoolAreaBookKeeper
Definition: LWPoolAreaBookKeeper.h:30
LWPoolArea::isUnused
bool isUnused() const
LWPoolArea::m_area
char * m_area
Definition: LWPoolArea.h:64
LWPoolArea::LWPoolArea
LWPoolArea(unsigned chunksize, unsigned nchunks)
LWPoolArea::m_nchunks
const unsigned m_nchunks
Definition: LWPoolArea.h:62
LWPoolArea::acquire
char * acquire()
LWPoolArea::calcNChunks
static unsigned calcNChunks(unsigned chunksize, unsigned length_of_mem)
Definition: LWPoolArea.cxx:21
LWPoolAreaBookKeeper.h
LWPoolArea
Definition: LWPoolArea.h:25
LWPoolArea::m_bookkeep
LWPoolAreaBookKeeper * m_bookkeep
Definition: LWPoolArea.h:63
LWPoolArea::totalNumberOfChunks
unsigned totalNumberOfChunks() const
Definition: LWPoolArea.h:52
LWPoolArea::~LWPoolArea
~LWPoolArea()
Definition: LWPoolArea.h:60
python.compressB64.c
def c
Definition: compressB64.py:93
LWPoolArea::LWPoolArea
LWPoolArea(const LWPoolArea &)
LWPoolArea::getMemDishedOut
long long getMemDishedOut() const