CppELib 1.7.0
|
Abstract class that has functions of common RTOS's fixed-size memory pool. More...
#include <FixedMemoryPool.h>
Public Member Functions | |
virtual void * | allocate ()=0 |
Allocate a block from this FixedMemoryPool. | |
virtual void | deallocate (void *p)=0 |
Release the allocated block. | |
virtual std::size_t | getBlockSize () const =0 |
Get the block size. | |
virtual Error | allocateMemory (void **memory) |
Block the current thread until a memory block is allocated from this FixedMemoryPool. | |
virtual Error | tryAllocateMemory (void **memory) |
Try to allocate a memory block from this FixedMemoryPool without blocking. | |
virtual Error | timedAllocateMemory (void **memory, Timeout tmout) |
Block the current thread until a memory block is allocated from this FixedMemoryPool but only within the limited time. | |
virtual std::size_t | getNumberOfAvailableBlocks () const |
Get the remaining number of available blocks in this FixedMemoryPool. | |
virtual std::size_t | getMaxNumberOfBlocks () const |
Get the max number of blocks in this FixedMemoryPool. | |
Static Public Member Functions | |
static FixedMemoryPool * | create (std::size_t blockSize, std::size_t memoryPoolSize, void *memoryPoolAddress=0) |
Create a FixedMemoryPool object. | |
static void | destroy (FixedMemoryPool *p) |
Destroy a FixedMemoryPool object. | |
static std::size_t | getRequiredMemorySize (std::size_t blockSize, std::size_t numBlocks) |
Get the required total memory size for allocation of (blockSize * numBlocks) | |
Protected Member Functions | |
virtual | ~FixedMemoryPool () |
Abstract class that has functions of common RTOS's fixed-size memory pool.
|
inlineprotectedvirtual |
|
pure virtual |
Allocate a block from this FixedMemoryPool.
Implemented in StdCppOSWrapper::StdCppFixedMemoryPool, and TestDoubleOSWrapper::TestDoubleFixedMemoryPool.
|
virtual |
Block the current thread until a memory block is allocated from this FixedMemoryPool.
[out] | memory | Pointer of pointer that stores the allocated memory |
OK | Success. A memory is allocated |
InvalidParameter | Parameter memory is null pointer |
CalledByNonThread | Called from non thread context (interrupt handler, timer, etc) |
OtherError | Not implemented in concrete class |
Reimplemented in StdCppOSWrapper::StdCppFixedMemoryPool.
|
static |
Create a FixedMemoryPool object.
blockSize | Number of bytes of one fixed-size memory block |
memoryPoolSize | Number of bytes of memory pool |
memoryPoolAddress | Memory pool address |
|
pure virtual |
Release the allocated block.
p | Pointer of allocated block |
Implemented in StdCppOSWrapper::StdCppFixedMemoryPool, and TestDoubleOSWrapper::TestDoubleFixedMemoryPool.
|
static |
Destroy a FixedMemoryPool object.
p | Pointer of FixedMemoryPool object created by FixedMemoryPool::create() |
|
pure virtual |
Get the block size.
Implemented in StdCppOSWrapper::StdCppFixedMemoryPool, and TestDoubleOSWrapper::TestDoubleFixedMemoryPool.
|
virtual |
Get the max number of blocks in this FixedMemoryPool.
Reimplemented in StdCppOSWrapper::StdCppFixedMemoryPool.
|
virtual |
Get the remaining number of available blocks in this FixedMemoryPool.
Reimplemented in StdCppOSWrapper::StdCppFixedMemoryPool.
|
static |
Get the required total memory size for allocation of (blockSize * numBlocks)
blockSize | Number of bytes of one fixed-size memory block |
numBlocks | Number of blocks |
Block the current thread until a memory block is allocated from this FixedMemoryPool but only within the limited time.
[out] | memory | Pointer of pointer that stores the allocated memory |
tmout | The limited time |
OK | Success. A memory is allocated |
TimedOut | The limited time was elapsed |
InvalidParameter | Parameter memory is null pointer |
CalledByNonThread | Called from non thread context (interrupt handler, timer, etc) |
OtherError | Not implemented in concrete class |
Reimplemented in StdCppOSWrapper::StdCppFixedMemoryPool.
|
virtual |
Try to allocate a memory block from this FixedMemoryPool without blocking.
[out] | memory | Pointer of pointer that stores the allocated memory |
OK | Success. A memory is allocated |
TimedOut | Failed. No memory blocks available |
InvalidParameter | Parameter memory is null pointer |
OtherError | Not implemented in concrete class |
Reimplemented in StdCppOSWrapper::StdCppFixedMemoryPool.