A MemoryManager that allocates fixed-size objects and maintains a freelist that never shrinks.
More...
Inherits G3D::ReferenceCountedObject.
|
virtual | ~BlockPoolMemoryManager () |
|
virtual void * | alloc (size_t s) |
| Return a pointer to s bytes of memory that are unused by the rest of the program. More...
|
|
size_t | blockSize () const |
|
virtual void | free (void *_ptr) |
| Invoke to declare that this memory will no longer be used by the program. More...
|
|
int | freeListNumBlocks () const |
| Returns the number of blocks currently sitting in the free list. More...
|
|
virtual bool | isThreadsafe () const |
| Returns true if this memory manager is threadsafe (i.e., alloc and free can be called asychronously) More...
|
|
int | peakNumBlocks () const |
| Total number of blocks ever allocated at once. More...
|
|
|
template<class T , class ... ArgTypes> |
static shared_ptr< T > | createShared (ArgTypes &&... args) |
| Like std::make_shared, but works for protected constructors. More...
|
|
A MemoryManager that allocates fixed-size objects and maintains a freelist that never shrinks.
Useful for sharing work buffers among threads.
◆ BlockPoolMemoryManager()
G3D::BlockPoolMemoryManager::BlockPoolMemoryManager |
( |
size_t |
s | ) |
|
|
inlineprotected |
◆ ~BlockPoolMemoryManager()
virtual G3D::BlockPoolMemoryManager::~BlockPoolMemoryManager |
( |
| ) |
|
|
inlinevirtual |
◆ alloc()
virtual void* G3D::BlockPoolMemoryManager::alloc |
( |
size_t |
s | ) |
|
|
inlinevirtual |
Return a pointer to s bytes of memory that are unused by the rest of the program.
The contents of the memory are undefined
◆ blockSize()
size_t G3D::BlockPoolMemoryManager::blockSize |
( |
| ) |
const |
|
inline |
◆ create()
Creates a new instance.
Each instance is allowed to have its own block size.
◆ createShared()
template<class T , class ... ArgTypes>
static shared_ptr<T> G3D::ReferenceCountedObject::createShared |
( |
ArgTypes &&... |
args | ) |
|
|
inlinestaticprotectedinherited |
Like std::make_shared, but works for protected constructors.
Call as createShared<myclass>.
◆ free()
virtual void G3D::BlockPoolMemoryManager::free |
( |
void * |
_ptr | ) |
|
|
inlinevirtual |
Invoke to declare that this memory will no longer be used by the program.
The memory manager is not required to actually reuse or release this memory.
◆ freeListNumBlocks()
int G3D::BlockPoolMemoryManager::freeListNumBlocks |
( |
| ) |
const |
|
inline |
Returns the number of blocks currently sitting in the free list.
◆ isThreadsafe()
virtual bool G3D::BlockPoolMemoryManager::isThreadsafe |
( |
| ) |
const |
|
inlinevirtual |
Returns true if this memory manager is threadsafe (i.e., alloc and free can be called asychronously)
◆ peakNumBlocks()
int G3D::BlockPoolMemoryManager::peakNumBlocks |
( |
| ) |
const |
|
inline |
Total number of blocks ever allocated at once.
◆ m_allBlocks
Set<uint32*> G3D::BlockPoolMemoryManager::m_allBlocks |
|
protected |
◆ m_blockSize
const size_t G3D::BlockPoolMemoryManager::m_blockSize |
|
protected |
◆ m_freeList
◆ m_mutex
std::mutex G3D::BlockPoolMemoryManager::m_mutex |
|
mutableprotected |