CernVM-FS
2.12.0
|
Public Member Functions | |
MemoryAllocator (const unsigned int num_slots) | |
virtual | ~MemoryAllocator () |
bool | IsFull () const |
T * | Construct (const T object) |
void | Destruct (T *object) |
T * | Allocate () |
void | Deallocate (T *slot) |
uint64_t | bytes_allocated () |
Static Public Member Functions | |
static double | GetEntrySize () |
Private Member Functions | |
bool | GetBit (const unsigned position) |
void | SetBit (const unsigned position) |
void | UnsetBit (const unsigned position) |
Private Member Functions inherited from SingleCopy | |
SingleCopy () | |
Private Attributes | |
unsigned int | num_slots_ |
unsigned int | num_free_slots_ |
unsigned int | next_free_slot_ |
uint64_t | bytes_allocated_ |
uint64_t * | bitmap_ |
unsigned | bits_per_block_ |
T * | memory_ |
A special purpose memory allocator for the cache entries. It allocates enough memory for the maximal number of cache entries at startup, and assigns new ListEntryContent objects to a free spot in this memory pool (by overriding the 'new' and 'delete' operators of ListEntryContent).
T | the type of object to be allocated by this MemoryAllocator |
|
inlineexplicit |
Creates a MemoryAllocator to handle a memory pool for objects of type T
num_slots | the number of slots to be allocated for the given datatype T |
|
inlinevirtual |
|
inline |
Allocate a slot and returns a pointer to the memory.
Definition at line 202 of file lru.h.
Referenced by lru::LruCache< Key, Value >::MemoryAllocator< ConcreteListEntryContent >::Construct().
|
inline |
Definition at line 245 of file lru.h.
Referenced by lru::LruCache< shash::Any, MemoryBuffer >::Drop(), and lru::LruCache< shash::Any, MemoryBuffer >::LruCache().
|
inline |
Definition at line 185 of file lru.h.
Referenced by lru::LruCache< Key, Value >::ListEntryHead< fuse_ino_t >::PushBack().
|
inline |
Free a given slot in the memory pool
slot | a pointer to the slot be freed |
Definition at line 229 of file lru.h.
Referenced by lru::LruCache< Key, Value >::MemoryAllocator< ConcreteListEntryContent >::Destruct().
|
inline |
Definition at line 193 of file lru.h.
Referenced by lru::LruCache< Key, Value >::ListEntryHead< fuse_ino_t >::clear(), lru::LruCache< shash::Any, MemoryBuffer >::FilterDelete(), lru::LruCache< shash::Any, MemoryBuffer >::Forget(), and lru::LruCache< Key, Value >::ListEntryHead< fuse_ino_t >::Pop().
|
inlineprivate |
Check a bit in the internal allocation bitmap.
position | the position to check |
Definition at line 253 of file lru.h.
Referenced by lru::LruCache< Key, Value >::MemoryAllocator< ConcreteListEntryContent >::Allocate(), and lru::LruCache< Key, Value >::MemoryAllocator< ConcreteListEntryContent >::Deallocate().
|
inlinestatic |
|
inline |
Check if the memory pool is full.
Definition at line 183 of file lru.h.
Referenced by lru::LruCache< Key, Value >::MemoryAllocator< ConcreteListEntryContent >::Allocate().
|
inlineprivate |
set a bit in the internal allocation bitmap
position | the number of the bit to be set |
Definition at line 263 of file lru.h.
Referenced by lru::LruCache< Key, Value >::MemoryAllocator< ConcreteListEntryContent >::Allocate().
|
inlineprivate |
Clear a bit in the internal allocation bitmap
position | the number of the bit to be cleared |
Definition at line 273 of file lru.h.
Referenced by lru::LruCache< Key, Value >::MemoryAllocator< ConcreteListEntryContent >::Deallocate().
|
private |
A bitmap to mark slots as allocated.
Definition at line 283 of file lru.h.
Referenced by lru::LruCache< Key, Value >::MemoryAllocator< ConcreteListEntryContent >::Allocate(), lru::LruCache< Key, Value >::MemoryAllocator< ConcreteListEntryContent >::GetBit(), lru::LruCache< Key, Value >::MemoryAllocator< ConcreteListEntryContent >::MemoryAllocator(), lru::LruCache< Key, Value >::MemoryAllocator< ConcreteListEntryContent >::SetBit(), lru::LruCache< Key, Value >::MemoryAllocator< ConcreteListEntryContent >::UnsetBit(), and lru::LruCache< Key, Value >::MemoryAllocator< ConcreteListEntryContent >::~MemoryAllocator().
|
private |
Definition at line 284 of file lru.h.
Referenced by lru::LruCache< Key, Value >::MemoryAllocator< ConcreteListEntryContent >::Allocate(), lru::LruCache< Key, Value >::MemoryAllocator< ConcreteListEntryContent >::GetBit(), lru::LruCache< Key, Value >::MemoryAllocator< ConcreteListEntryContent >::MemoryAllocator(), lru::LruCache< Key, Value >::MemoryAllocator< ConcreteListEntryContent >::SetBit(), and lru::LruCache< Key, Value >::MemoryAllocator< ConcreteListEntryContent >::UnsetBit().
|
private |
Definition at line 282 of file lru.h.
Referenced by lru::LruCache< Key, Value >::MemoryAllocator< ConcreteListEntryContent >::bytes_allocated(), and lru::LruCache< Key, Value >::MemoryAllocator< ConcreteListEntryContent >::MemoryAllocator().
|
private |
The memory pool, array of Ms.
Definition at line 285 of file lru.h.
Referenced by lru::LruCache< Key, Value >::MemoryAllocator< ConcreteListEntryContent >::Allocate(), lru::LruCache< Key, Value >::MemoryAllocator< ConcreteListEntryContent >::Deallocate(), lru::LruCache< Key, Value >::MemoryAllocator< ConcreteListEntryContent >::MemoryAllocator(), and lru::LruCache< Key, Value >::MemoryAllocator< ConcreteListEntryContent >::~MemoryAllocator().
|
private |
Position of next free slot in pool.
Definition at line 281 of file lru.h.
Referenced by lru::LruCache< Key, Value >::MemoryAllocator< ConcreteListEntryContent >::Allocate(), lru::LruCache< Key, Value >::MemoryAllocator< ConcreteListEntryContent >::Deallocate(), and lru::LruCache< Key, Value >::MemoryAllocator< ConcreteListEntryContent >::MemoryAllocator().
|
private |
Current number of free slots left.
Definition at line 280 of file lru.h.
Referenced by lru::LruCache< Key, Value >::MemoryAllocator< ConcreteListEntryContent >::Allocate(), lru::LruCache< Key, Value >::MemoryAllocator< ConcreteListEntryContent >::Deallocate(), lru::LruCache< Key, Value >::MemoryAllocator< ConcreteListEntryContent >::IsFull(), and lru::LruCache< Key, Value >::MemoryAllocator< ConcreteListEntryContent >::MemoryAllocator().
|
private |
Overall number of slots in memory pool.
Definition at line 279 of file lru.h.
Referenced by lru::LruCache< Key, Value >::MemoryAllocator< ConcreteListEntryContent >::Allocate(), lru::LruCache< Key, Value >::MemoryAllocator< ConcreteListEntryContent >::Deallocate(), lru::LruCache< Key, Value >::MemoryAllocator< ConcreteListEntryContent >::GetBit(), lru::LruCache< Key, Value >::MemoryAllocator< ConcreteListEntryContent >::MemoryAllocator(), lru::LruCache< Key, Value >::MemoryAllocator< ConcreteListEntryContent >::SetBit(), and lru::LruCache< Key, Value >::MemoryAllocator< ConcreteListEntryContent >::UnsetBit().