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);
void print_performance_info() const
Prints out performance info.
unsigned int size() const
Get size of data segment.
ChunkIterator begin()
Get first element for chunk iteration.
unsigned int allocated_size() const
Get total allocated memory.
bool is_master() const
Check if this BB memory manager is the master.
void print_allocated_chunks_info() const
Print out info about allocated chunks.
Fawkes library namespace.
ChunkIterator end()
Get end of chunk list.
BlackBoard memory manager.
unsigned int memory_size() const
Get size of memory.
chunk_list_t * next
offset to next element in list
void * alloc(unsigned int num_bytes)
Allocate memory.
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 overhang
number of overhanging bytes in this chunk
BlackBoardMemoryManager(size_t memsize)
Heap Memory Constructor.
ChunkIterator & operator++()
Increment iterator.
unsigned int version() const
Get BlackBoard version.
ChunkIterator & operator+=(unsigned int i)
Advance by a certain amount.
void print_free_chunks_info() const
Print out info about free chunks.
unsigned int num_free_chunks() const
Get number of free chunks.
void * ptr
pointer to data memory
bool operator!=(const ChunkIterator &c) const
Check inequality of two iterators.
ChunkIterator & operator+(unsigned int i)
Advance by a certain amount.
ChunkIterator()
Constructor.
void * operator*() const
Get memory pointer of chunk.
unsigned int free_size() const
Get total free memory.
Iterator for memory chunks.
unsigned int overhang() const
Get number of overhanging bytes.
void unlock()
Unlock memory.
void check()
Check memory consistency.
unsigned int max_allocated_size() const
Get maximum alloced memory size.
void free(void *chunk_ptr)
Free a memory chunk.
bool operator==(const ChunkIterator &c) const
Check equality of two iterators.
~BlackBoardMemoryManager()
Destructor.
Mutex mutual exclusion lock.
unsigned int num_allocated_chunks() const
Get number of allocated chunks.
unsigned int max_free_size() const
Get maximum allocatable memory size.
BlackBoard interface manager.
ChunkIterator & operator=(const ChunkIterator &c)
Assign iterator.
unsigned int overhang_size() const
Get number of overhanging bytes.