Rogue Wave Views 5.6 |
Rogue Wave Views |
Rogue Wave Views Documentation Home |
A generic class that handles memory pools. More...
#include <ilog/pool.h>
Static Public Member Functions | |
static TYPE * | Alloc (IlUInt nElements, IlBoolean lock=IlFalse) |
Allocates a block of memory. More... | |
static TYPE * | Lock (TYPE *data) |
Locks a data block. More... | |
static TYPE * | ReAlloc (TYPE *data, IlUInt nElements, IlBoolean lock=IlFalse) |
Re-allocates a data block. More... | |
static TYPE * | UnLock (TYPE *data) |
Unlocks a data block. More... | |
A generic class that handles memory pools.
Library: ilog
Memory pools offer the advantage of greatly simplifying the handling the allocation, locking and deallocation of chunks of memory that can be used by your applications.
The complete body of this class is generated by the macros IlDeclarePoolOf(NAME, TYPE)
and IlDefinePoolOf(NAME, TYPE)
, that respectively declare and define a class called IlPoolOf(NAME)
that manages a memory pool for objects of the type TYPE
.
A given pool can manage only arrays of TYPE
, but it can manage as many of those memory blocks as needed. To get an array, you simply call the static member function IlPoolOf(NAME)::Alloc(n);
, and a memory block large enough to hold n elements of type TYPE
will be returned to you.
Note that if you repeat this call, you may receive the same memory block (because it may already be large enough to fit your needs). If you actually want another block to be allocated and returned to you, you must lock the first block, using the static member function IlPoolOf(NAME)::Lock(data);
. This ensures that the next call to Alloc()
will not return the same memory block. To unlock a memory block that you have locked, you must call UnLock()
.
Many functions in Rogue Wave Views will return memory blocks that are managed by pools. Therefore:
Allocates a block of memory.
nElements | The number of elements to allocate. |
lock | Set this to IlTrue to lock the associated data block. |
TYPE
. This pointer is managed by a new data block or a data block that is not locked.
|
static |
Locks a data block.
Locking a data block ensures that no allocation request on this pool will be authorized to return this block.
data | The data block to be locked. |
|
static |
Re-allocates a data block.
data | The data block to be re-allocated. |
nElements | The number of elements that are needed. |
lock | Can be set to IlTrue to lock the returned data block. |
|
static |
Unlocks a data block.
When you unlock a data block, any allocation request on this pool is authorized to return the same data block.
data | The data block to be unlocked. |
© Copyright 2012, Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave is a registered trademark of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.