CppELib 1.7.0
Loading...
Searching...
No Matches
StdCppOSWrapper::StdCppFixedMemoryPool Class Reference

Public Member Functions

 StdCppFixedMemoryPool (std::size_t blockSize, std::size_t maxBlocks, std::size_t memoryPoolSize, void *memoryPoolAddress)
 
 ~StdCppFixedMemoryPool ()
 
void * allocate ()
 
void deallocate (void *p)
 Release the allocated block.
 
std::size_t getBlockSize () const
 Get the block size.
 
OSWrapper::Error allocateMemory (void **memory)
 Block the current thread until a memory block is allocated from this FixedMemoryPool.
 
OSWrapper::Error tryAllocateMemory (void **memory)
 Try to allocate a memory block from this FixedMemoryPool without blocking.
 
OSWrapper::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.
 
std::size_t getNumberOfAvailableBlocks () const
 Get the remaining number of available blocks in this FixedMemoryPool.
 
std::size_t getMaxNumberOfBlocks () const
 Get the max number of blocks in this FixedMemoryPool.
 

Additional Inherited Members

- Static Public Member Functions inherited from OSWrapper::FixedMemoryPool
static FixedMemoryPoolcreate (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 inherited from OSWrapper::FixedMemoryPool
virtual ~FixedMemoryPool ()
 

Constructor & Destructor Documentation

◆ StdCppFixedMemoryPool()

StdCppOSWrapper::StdCppFixedMemoryPool::StdCppFixedMemoryPool ( std::size_t  blockSize,
std::size_t  maxBlocks,
std::size_t  memoryPoolSize,
void *  memoryPoolAddress 
)
inlineexplicit

◆ ~StdCppFixedMemoryPool()

StdCppOSWrapper::StdCppFixedMemoryPool::~StdCppFixedMemoryPool ( )
inline

Member Function Documentation

◆ allocate()

void * StdCppOSWrapper::StdCppFixedMemoryPool::allocate ( )
inlinevirtual
Deprecated:
The implementation of this method is not satisfied the specification. Use allocateMemory(), tryAllocateMemory(), or timedAllocateMemory() instead of this.

Implements OSWrapper::FixedMemoryPool.

◆ allocateMemory()

OSWrapper::Error StdCppOSWrapper::StdCppFixedMemoryPool::allocateMemory ( void **  memory)
inlinevirtual

Block the current thread until a memory block is allocated from this FixedMemoryPool.

Parameters
[out]memoryPointer of pointer that stores the allocated memory
Return values
OKSuccess. A memory is allocated
InvalidParameterParameter memory is null pointer
CalledByNonThreadCalled from non thread context (interrupt handler, timer, etc)
OtherErrorNot implemented in concrete class
Note
Call deallocate() to release a memory block allocated by this method
Same as timedAllocateMemory(memory, Timeout::FOREVER)

Reimplemented from OSWrapper::FixedMemoryPool.

◆ deallocate()

void StdCppOSWrapper::StdCppFixedMemoryPool::deallocate ( void *  p)
inlinevirtual

Release the allocated block.

Parameters
pPointer of allocated block
Note
If p is null pointer, do nothing.

Implements OSWrapper::FixedMemoryPool.

◆ getBlockSize()

std::size_t StdCppOSWrapper::StdCppFixedMemoryPool::getBlockSize ( ) const
inlinevirtual

Get the block size.

Returns
Number of bytes of one fixed-size memory block

Implements OSWrapper::FixedMemoryPool.

◆ getMaxNumberOfBlocks()

std::size_t StdCppOSWrapper::StdCppFixedMemoryPool::getMaxNumberOfBlocks ( ) const
inlinevirtual

Get the max number of blocks in this FixedMemoryPool.

Returns
Max number of blocks
Note
If the concrete class does not implement this method, this method returns 0

Reimplemented from OSWrapper::FixedMemoryPool.

◆ getNumberOfAvailableBlocks()

std::size_t StdCppOSWrapper::StdCppFixedMemoryPool::getNumberOfAvailableBlocks ( ) const
inlinevirtual

Get the remaining number of available blocks in this FixedMemoryPool.

Returns
Remaining number of available blocks
Note
If the concrete class does not implement this method, this method returns 0

Reimplemented from OSWrapper::FixedMemoryPool.

◆ timedAllocateMemory()

OSWrapper::Error StdCppOSWrapper::StdCppFixedMemoryPool::timedAllocateMemory ( void **  memory,
Timeout  tmout 
)
inlinevirtual

Block the current thread until a memory block is allocated from this FixedMemoryPool but only within the limited time.

Parameters
[out]memoryPointer of pointer that stores the allocated memory
tmoutThe limited time
Return values
OKSuccess. A memory is allocated
TimedOutThe limited time was elapsed
InvalidParameterParameter memory is null pointer
CalledByNonThreadCalled from non thread context (interrupt handler, timer, etc)
OtherErrorNot implemented in concrete class
Note
Call deallocate() to release a memory block allocated by this method
If tmout is Timeout::POLLING then this method tries to allocate a memory block without blocking.
If tmout is Timeout::FOREVER then this method waits forever until a memory block is allocated.

Reimplemented from OSWrapper::FixedMemoryPool.

◆ tryAllocateMemory()

OSWrapper::Error StdCppOSWrapper::StdCppFixedMemoryPool::tryAllocateMemory ( void **  memory)
inlinevirtual

Try to allocate a memory block from this FixedMemoryPool without blocking.

Parameters
[out]memoryPointer of pointer that stores the allocated memory
Return values
OKSuccess. A memory is allocated
TimedOutFailed. No memory blocks available
InvalidParameterParameter memory is null pointer
OtherErrorNot implemented in concrete class
Note
Call deallocate() to release a memory block allocated by this method
Same as timedAllocateMemory(memory, Timeout::POLLING)

Reimplemented from OSWrapper::FixedMemoryPool.


The documentation for this class was generated from the following file: