|
pion-net
4.0.9
|
#include <PionPoolAllocator.hpp>
Inherits noncopyable.
Classes | |
| struct | FixedSizeAlloc |
Public Member Functions | |
| virtual | ~PionPoolAllocator () |
| virtual destructor | |
| PionPoolAllocator (void) | |
| default constructor | |
| void * | malloc (std::size_t n) |
| void | free (void *ptr, std::size_t n) |
| bool | release_memory (size_t pad=10240000UL) |
Protected Types | |
| enum | { NumberOfAllocs = ((MaxSize-1) / MinSize) + 1 } |
| constant representing the number of fixed-size pool allocators | |
| typedef void * | FreeListPtr |
Protected Member Functions | |
| BOOST_STATIC_ASSERT (MaxSize >=MinSize) | |
| BOOST_STATIC_ASSERT (MaxSize%MinSize==0) | |
| FixedSizeAlloc * | getPool (const std::size_t n) |
PionPoolAllocator: a thread-safe, small object allocator that sacrifices memory utilization for performance. It combines a collection of fixed-size pooled memory allocators with lock-free caches to achieve nearly wait-free, constant time performance when used for an extended period of time
Definition at line 52 of file PionPoolAllocator.hpp.
|
protected |
ensure that: a) MaxSize >= MinSize b) MaxSize is a multiple of MinSize c) MinSize >= sizeof(FreeNodePtr) [usually 16]
Referenced by pion::PionPoolAllocator< MinSize, MaxSize >::release_memory().
|
inline |
deallocates a block of memory
| ptr | raw pointer to the block of memory |
| n | requested size of the memory block, in bytes (actual size may be larger) |
Definition at line 106 of file PionPoolAllocator.hpp.
References pion::PionPoolAllocator< MinSize, MaxSize >::getPool(), pion::PionPoolAllocator< MinSize, MaxSize >::FixedSizeAlloc::m_free_ptr, pion::PionPoolAllocator< MinSize, MaxSize >::FixedSizeAlloc::m_mutex, and pion::PionPoolAllocator< MinSize, MaxSize >::FixedSizeAlloc::m_pool.
|
inlineprotected |
gets an appropriate fixed-size pool allocator
| n | the number of bytes to be (de)allocated |
Definition at line 236 of file PionPoolAllocator.hpp.
Referenced by pion::PionPoolAllocator< MinSize, MaxSize >::free(), and pion::PionPoolAllocator< MinSize, MaxSize >::malloc().
|
inline |
allocates a block of memory
| n | minimum size of the new memory block, in bytes |
Definition at line 76 of file PionPoolAllocator.hpp.
References pion::PionPoolAllocator< MinSize, MaxSize >::getPool(), pion::PionPoolAllocator< MinSize, MaxSize >::FixedSizeAlloc::m_free_ptr, pion::PionPoolAllocator< MinSize, MaxSize >::FixedSizeAlloc::m_mutex, and pion::PionPoolAllocator< MinSize, MaxSize >::FixedSizeAlloc::m_pool.
|
inline |
releases every memory block that does not have any allocated chunks
| pad | padding bytes passed to malloc_trim(), if it's supported (default=10MB) |
Definition at line 141 of file PionPoolAllocator.hpp.
References pion::PionPoolAllocator< MinSize, MaxSize >::BOOST_STATIC_ASSERT().
1.8.11