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