BDE 4.14.0 Production release
|
Typedefs | |
typedef bsls::BlockGrowth | bsls_BlockGrowth |
This alias is defined for backward compatibility. | |
Provide a namespace for memory block growth strategies.
This component provides a namespace for enumerating memory block growth strategies, and provides a function that converts each of these enumerators to its corresponding string representation.
This component supports two memory block growth strategies:
GEOMETRIC GROWTH: A container, pool or allocator that employs this strategy, as indicated by the enumerator BSLS_GEOMETRIC
, grows its buffer geometrically.
CONSTANT GROWTH: A container, pool or allocator that employs this strategy, as indicated by the enumerator BSLS_CONSTANT
, locks the buffer growth. The new buffer is always the same size as the current buffer.
Memory block growth strategies are often used in memory managers and containers to control memory usage. First of all, suppose we have a my_BlockList
class that manages a link list of memory blocks:
We can then create a memory manager class my_SequentialPool
that manages a pool of memory:
The implementation for the rest of the class is elided as the function calculateNextSize
alone is sufficient to illustrate the use of this component:
Note that, if the growth strategy in effect is constant growth (BSLS_CONSTANT
), the size of the internal buffers will always be the same. If size
is greater than the buffer size, the implementation of allocate
will return a block having the exact size
from the internal block list:
Note that, if the growth strategy in effect is geometric growth (BSLS_GEOMETRIC
), the size of the internal buffer grows geometrically by a factor of 2:
typedef bsls::BlockGrowth bsls_BlockGrowth |