![]() |
CernVM-FS
2.13.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) |
![]() | |
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 207 of file lru.h.
Referenced by lru::LruCache< Key, Value >::MemoryAllocator< ConcreteListEntryContent >::Construct().
|
inline |
Definition at line 250 of file lru.h.
Referenced by lru::LruCache< shash::Any, MemoryBuffer >::Drop(), and lru::LruCache< shash::Any, MemoryBuffer >::LruCache().
|
inline |
Definition at line 190 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 234 of file lru.h.
Referenced by lru::LruCache< Key, Value >::MemoryAllocator< ConcreteListEntryContent >::Destruct().
|
inline |
Definition at line 198 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 258 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 188 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 269 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 279 of file lru.h.
Referenced by lru::LruCache< Key, Value >::MemoryAllocator< ConcreteListEntryContent >::Deallocate().
|
private |
A bitmap to mark slots as allocated.
Definition at line 289 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 290 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 288 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 291 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 287 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 286 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 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 >::GetBit(), lru::LruCache< Key, Value >::MemoryAllocator< ConcreteListEntryContent >::MemoryAllocator(), lru::LruCache< Key, Value >::MemoryAllocator< ConcreteListEntryContent >::SetBit(), and lru::LruCache< Key, Value >::MemoryAllocator< ConcreteListEntryContent >::UnsetBit().