24 #ifndef __BLACKBOARD_MEMORY_MANAGER_H_
25 #define __BLACKBOARD_MEMORY_MANAGER_H_
27 #include <sys/types.h>
31 class BlackBoardSharedMemoryHeader;
63 const char *shmem_token =
"FawkesBlackBoard");
66 void *
alloc(
unsigned int num_bytes);
67 void free(
void *chunk_ptr);
118 unsigned int size()
const;
133 unsigned int list_length(
const chunk_list_t *list)
const;
137 void cleanup_free_chunks();
141 void * alloc_nolock(
unsigned int num_bytes);
ChunkIterator begin()
Get first element for chunk iteration.
void print_performance_info() const
Prints out performance info.
void print_allocated_chunks_info() const
Print out info about allocated chunks.
unsigned int overhang_size() const
Get number of overhanging bytes.
ChunkIterator end()
Get end of chunk list.
void * operator*() const
Get memory pointer of chunk.
unsigned int size() const
Get size of data segment.
unsigned int overhang() const
Get number of overhanging bytes.
BlackBoard memory manager.
bool is_master() const
Check if this BB memory manager is the master.
bool operator==(const ChunkIterator &c) const
Check equality of two iterators.
chunk_list_t * next
offset to next element in list
void * alloc(unsigned int num_bytes)
Allocate memory.
unsigned int num_allocated_chunks() const
Get number of allocated chunks.
void print_free_chunks_info() const
Print out info about free chunks.
unsigned int size
total size of chunk, including overhanging bytes, excluding header
bool try_lock()
Try to lock memory.
Chunk lists as stored in BlackBoard shared memory segment.
unsigned int max_allocated_size() const
Get maximum alloced memory size.
unsigned int overhang
number of overhanging bytes in this chunk
BlackBoardMemoryManager(size_t memsize)
Heap Memory Constructor.
ChunkIterator & operator++()
Increment iterator.
ChunkIterator & operator+=(unsigned int i)
Advance by a certain amount.
void * ptr
pointer to data memory
ChunkIterator & operator+(unsigned int i)
Advance by a certain amount.
unsigned int max_free_size() const
Get maximum allocatable memory size.
ChunkIterator()
Constructor.
Iterator for memory chunks.
unsigned int memory_size() const
Get size of memory.
void unlock()
Unlock memory.
void check()
Check memory consistency.
void free(void *chunk_ptr)
Free a memory chunk.
unsigned int version() const
Get BlackBoard version.
~BlackBoardMemoryManager()
Destructor.
bool operator!=(const ChunkIterator &c) const
Check inequality of two iterators.
Mutex mutual exclusion lock.
BlackBoard interface manager.
unsigned int allocated_size() const
Get total allocated memory.
ChunkIterator & operator=(const ChunkIterator &c)
Assign iterator.
unsigned int free_size() const
Get total free memory.
unsigned int num_free_chunks() const
Get number of free chunks.