ATLAS Offline Software
LWPoolAreaBookKeeper.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 LWPoolAreaBookKeeper //
9 // //
10 // Description: Helper class for keeping track of which //
11 // chunks in a pool area have been dished out. //
12 // //
13 // The internal book-keeping overhead is 1 bit //
14 // per entry (plus a contribution which is //
15 // negligible for high nEntries) //
16 // //
17 // Author: Thomas H. Kittelmann (Thomas.Kittelmann@cern.ch) //
18 // Initial version: April 2009 //
19 // //
21 
22 #ifndef LWPOOLAREABOOKKEEPER_H
23 #define LWPOOLAREABOOKKEEPER_H
24 
25 #include <stdint.h>
26 #include <cassert>
27 #include <climits>//for CHAR_BIT and UINT_MAX
28 #include <cstring>//for memset(..) and ffs(..)
29 
31 public:
32 
33  //Methods used for creating objects, this tricky procedure is to
34  //ensure cache-locality and remove internal malloc's (to destroy,
35  //simply release the memory - no need for the destructor)
36  static unsigned nBytesNeededForCreate(unsigned nEntries);
37  static LWPoolAreaBookKeeper * create(char *, unsigned nEntries);
38  unsigned nBytesCovered() const;
39 
40  unsigned acquireEntry();//Returns UINT_MAX when none are available.
41  void returnEntry(unsigned);
42  bool isCompletelyFull() const;
43  bool isCompletelyEmpty() const;
44  unsigned numberOfAvailableEntries() const;
45  unsigned numberOfEntriesHandedOut() const;
46 
47 private:
48  typedef unsigned BitField;
49 #ifndef NDEBUG
50  friend class LWPoolArea;
51 #endif
52  const unsigned m_nEntries;
53  const unsigned m_nFields;
54  unsigned m_nonEmptyField;//set to UINT_MAX when all are empty
55  unsigned m_nUnusedEntries;
56 
57 private:
62  static unsigned nFields(unsigned nEntries);
63  void findNewNonEmptyField();
64 #define LW_ENTRIESPERGROUP (CHAR_BIT*sizeof(BitField))
65 };
66 
67 #include "LWPoolAreaBookKeeper.icc"
68 
69 #endif
LWPoolAreaBookKeeper::m_nUnusedEntries
unsigned m_nUnusedEntries
Definition: LWPoolAreaBookKeeper.h:55
LWPoolAreaBookKeeper::isCompletelyEmpty
bool isCompletelyEmpty() const
LWPoolAreaBookKeeper::LWPoolAreaBookKeeper
LWPoolAreaBookKeeper(unsigned nEntries)
Definition: LWPoolAreaBookKeeper.cxx:49
LWPoolAreaBookKeeper::operator=
LWPoolAreaBookKeeper & operator=(const LWPoolAreaBookKeeper &)
LWPoolAreaBookKeeper::m_nEntries
const unsigned m_nEntries
Definition: LWPoolAreaBookKeeper.h:52
LWPoolAreaBookKeeper::BitField
unsigned BitField
Definition: LWPoolAreaBookKeeper.h:48
LWPoolAreaBookKeeper::acquireEntry
unsigned acquireEntry()
LWPoolAreaBookKeeper
Definition: LWPoolAreaBookKeeper.h:30
LWPoolAreaBookKeeper::nBytesCovered
unsigned nBytesCovered() const
Definition: LWPoolAreaBookKeeper.cxx:37
LWPoolAreaBookKeeper::nBytesNeededForCreate
static unsigned nBytesNeededForCreate(unsigned nEntries)
Definition: LWPoolAreaBookKeeper.cxx:25
LWPoolAreaBookKeeper.icc
LWPoolAreaBookKeeper::m_nFields
const unsigned m_nFields
Definition: LWPoolAreaBookKeeper.h:53
LWPoolAreaBookKeeper::m_nonEmptyField
unsigned m_nonEmptyField
Definition: LWPoolAreaBookKeeper.h:54
LWPoolAreaBookKeeper::findNewNonEmptyField
void findNewNonEmptyField()
Definition: LWPoolAreaBookKeeper.cxx:64
LWPoolAreaBookKeeper::isCompletelyFull
bool isCompletelyFull() const
LWPoolAreaBookKeeper::LWPoolAreaBookKeeper
LWPoolAreaBookKeeper(const LWPoolAreaBookKeeper &)
LWPoolArea
Definition: LWPoolArea.h:25
LWPoolAreaBookKeeper::numberOfAvailableEntries
unsigned numberOfAvailableEntries() const
LWPoolAreaBookKeeper::returnEntry
void returnEntry(unsigned)
LWPoolAreaBookKeeper::create
static LWPoolAreaBookKeeper * create(char *, unsigned nEntries)
Definition: LWPoolAreaBookKeeper.cxx:43
LWPoolAreaBookKeeper::~LWPoolAreaBookKeeper
~LWPoolAreaBookKeeper()
Definition: LWPoolAreaBookKeeper.h:59
LWPoolAreaBookKeeper::numberOfEntriesHandedOut
unsigned numberOfEntriesHandedOut() const
LWPoolAreaBookKeeper::nFields
static unsigned nFields(unsigned nEntries)
Definition: LWPoolAreaBookKeeper.cxx:31
dqBeamSpot.nEntries
int nEntries
Definition: dqBeamSpot.py:73