BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bdlma::BufferedSequentialPool Class Reference

#include <bdlma_bufferedsequentialpool.h>

Public Member Functions

 BufferedSequentialPool (char *buffer, bsls::Types::size_type size, bslma::Allocator *basicAllocator=0)
 
 BufferedSequentialPool (char *buffer, bsls::Types::size_type size, bsls::BlockGrowth::Strategy growthStrategy, bslma::Allocator *basicAllocator=0)
 
 BufferedSequentialPool (char *buffer, bsls::Types::size_type size, bsls::Alignment::Strategy alignmentStrategy, bslma::Allocator *basicAllocator=0)
 
 BufferedSequentialPool (char *buffer, bsls::Types::size_type size, bsls::BlockGrowth::Strategy growthStrategy, bsls::Alignment::Strategy alignmentStrategy, bslma::Allocator *basicAllocator=0)
 
 BufferedSequentialPool (char *buffer, bsls::Types::size_type size, bsls::Types::size_type maxBufferSize, bslma::Allocator *basicAllocator=0)
 
 BufferedSequentialPool (char *buffer, bsls::Types::size_type size, bsls::Types::size_type maxBufferSize, bsls::BlockGrowth::Strategy growthStrategy, bslma::Allocator *basicAllocator=0)
 
 BufferedSequentialPool (char *buffer, bsls::Types::size_type size, bsls::Types::size_type maxBufferSize, bsls::Alignment::Strategy alignmentStrategy, bslma::Allocator *basicAllocator=0)
 
 BufferedSequentialPool (char *buffer, bsls::Types::size_type size, bsls::Types::size_type maxBufferSize, bsls::BlockGrowth::Strategy growthStrategy, bsls::Alignment::Strategy alignmentStrategy, bslma::Allocator *basicAllocator=0)
 
 ~BufferedSequentialPool ()
 
void * allocate (bsls::Types::size_type size)
 
template<class TYPE >
void deleteObject (const TYPE *object)
 
template<class TYPE >
void deleteObjectRaw (const TYPE *object)
 
void release ()
 
void rewind ()
 
bslma::Allocatorallocator () const
 

Detailed Description

This class implements a fast memory pool that efficiently dispenses heterogeneous blocks of memory (of varying, user-specified sizes) from an external buffer whose address and size (in bytes) are supplied at construction. If an allocation request exceeds the remaining free memory space in the external buffer, memory will be supplied by an (optional) allocator supplied also at construction; if no allocator is supplied, the currently installed default allocator will be used. This class is exception neutral: If memory cannot be allocated, the behavior is defined by the (optional) allocator supplied at construction. Note that in no case will the buffered sequential pool attempt to deallocate the external buffer.

See bdlma_bufferedsequentialpool

Constructor & Destructor Documentation

◆ BufferedSequentialPool() [1/8]

bdlma::BufferedSequentialPool::BufferedSequentialPool ( char *  buffer,
bsls::Types::size_type  size,
bslma::Allocator basicAllocator = 0 
)

◆ BufferedSequentialPool() [2/8]

bdlma::BufferedSequentialPool::BufferedSequentialPool ( char *  buffer,
bsls::Types::size_type  size,
bsls::BlockGrowth::Strategy  growthStrategy,
bslma::Allocator basicAllocator = 0 
)

◆ BufferedSequentialPool() [3/8]

bdlma::BufferedSequentialPool::BufferedSequentialPool ( char *  buffer,
bsls::Types::size_type  size,
bsls::Alignment::Strategy  alignmentStrategy,
bslma::Allocator basicAllocator = 0 
)

◆ BufferedSequentialPool() [4/8]

bdlma::BufferedSequentialPool::BufferedSequentialPool ( char *  buffer,
bsls::Types::size_type  size,
bsls::BlockGrowth::Strategy  growthStrategy,
bsls::Alignment::Strategy  alignmentStrategy,
bslma::Allocator basicAllocator = 0 
)

Create a buffered sequential pool for allocating memory blocks from the specified external buffer having the specified size (in bytes), or from an internal buffer (after the external buffer is exhausted). Optionally specify a growthStrategy used to control buffer growth. If a growthStrategy is not specified, geometric growth is used. Optionally specify an alignmentStrategy used to align allocated memory blocks. If an alignmentStrategy is not specified, natural alignment is used. Optionally specify a basicAllocator used to supply memory should the capacity of buffer be exhausted. If basicAllocator is 0, the currently installed default allocator is used. The behavior is undefined unless 0 < size, and buffer has at least size bytes. Note that, due to alignment effects, it is possible that not all size bytes of memory in buffer can be used for allocation. Also note that no limit is imposed on the size of the internal buffers when geometric growth is used. Also note that when constant growth is used, the size of the internal buffers will always be the same as size.

◆ BufferedSequentialPool() [5/8]

bdlma::BufferedSequentialPool::BufferedSequentialPool ( char *  buffer,
bsls::Types::size_type  size,
bsls::Types::size_type  maxBufferSize,
bslma::Allocator basicAllocator = 0 
)

◆ BufferedSequentialPool() [6/8]

bdlma::BufferedSequentialPool::BufferedSequentialPool ( char *  buffer,
bsls::Types::size_type  size,
bsls::Types::size_type  maxBufferSize,
bsls::BlockGrowth::Strategy  growthStrategy,
bslma::Allocator basicAllocator = 0 
)

◆ BufferedSequentialPool() [7/8]

bdlma::BufferedSequentialPool::BufferedSequentialPool ( char *  buffer,
bsls::Types::size_type  size,
bsls::Types::size_type  maxBufferSize,
bsls::Alignment::Strategy  alignmentStrategy,
bslma::Allocator basicAllocator = 0 
)

◆ BufferedSequentialPool() [8/8]

bdlma::BufferedSequentialPool::BufferedSequentialPool ( char *  buffer,
bsls::Types::size_type  size,
bsls::Types::size_type  maxBufferSize,
bsls::BlockGrowth::Strategy  growthStrategy,
bsls::Alignment::Strategy  alignmentStrategy,
bslma::Allocator basicAllocator = 0 
)

Create a buffered sequential pool for allocating memory blocks from the specified external buffer having the specified size (in bytes), or from an internal buffer (after the external buffer is exhausted) where the buffer growth is limited to the specified maxBufferSize (in bytes). Optionally specify a growthStrategy used to control buffer growth. If a growthStrategy is not specified, geometric growth is used. Optionally specify an alignmentStrategy used to align allocated memory blocks. If an alignmentStrategy is not specified, natural alignment is used. Optionally specify a basicAllocator used to supply memory should the capacity of buffer be exhausted. If basicAllocator is 0, the currently installed default allocator is used. The behavior is undefined unless 0 < size, size <= maxBufferSize, and buffer has at least size bytes. Note that, due to alignment effects, it is possible that not all size bytes of memory in buffer can be used for allocation. Also note that when constant growth is used, the size of the internal buffers will always be the same as size.

◆ ~BufferedSequentialPool()

bdlma::BufferedSequentialPool::~BufferedSequentialPool ( )
inline

Destroy this buffered sequential pool. All memory allocated from this pool is released.

Member Function Documentation

◆ allocate()

void * bdlma::BufferedSequentialPool::allocate ( bsls::Types::size_type  size)
inline

Return the address of a contiguous block of memory of the specified size (in bytes) according to the alignment strategy specified at construction. If size is 0, no memory is allocated and 0 is returned. If the allocation request exceeds the remaining free memory space in the external buffer supplied at construction, use memory obtained from the allocator supplied at construction.

◆ allocator()

bslma::Allocator * bdlma::BufferedSequentialPool::allocator ( ) const
inline

Return the allocator used by this object to allocate memory. Note that this allocator can not be used to deallocate memory allocated through this pool.

◆ deleteObject()

template<class TYPE >
void bdlma::BufferedSequentialPool::deleteObject ( const TYPE *  object)
inline

Destroy the specified object. Note that this method has the same effect as the deleteObjectRaw method (since no deallocation is involved), and exists for consistency across memory pools.

◆ deleteObjectRaw()

template<class TYPE >
void bdlma::BufferedSequentialPool::deleteObjectRaw ( const TYPE *  object)
inline

Destroy the specified object. Note that memory associated with object is not deallocated because there is no deallocate method in BufferedSequentialPool.

◆ release()

void bdlma::BufferedSequentialPool::release ( )
inline

Release all memory allocated through this pool and return to the underlying allocator all memory except the external buffer supplied at construction. The pool is reset to its default-constructed state, making the memory from the entire external buffer supplied at construction available for subsequent allocations, retaining the alignment and growth strategies, and the initial and maximum buffer sizes in effect following construction. The effect of subsequently - to this invokation of release - using a pointer obtained from this object prior to this call to release is undefined.

◆ rewind()

void bdlma::BufferedSequentialPool::rewind ( )
inline

Release all memory allocated through this pool and return to the underlying allocator only memory that was allocated outside of the typical internal buffer growth of this pool (i.e., large blocks). All retained memory will be used to satisfy subsequent allocations. The effect of subsequently - to this invokation of rewind - using a pointer obtained from this object prior to this call to rewind is undefined.

Member Data Documentation

◆ d_allocator_p

bslma::Allocator* bdlma::BufferedSequentialPool::d_allocator_p

◆ d_pool_p

SequentialPool* bdlma::BufferedSequentialPool::d_pool_p

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