BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bslstl::SimplePool< VALUE, ALLOCATOR > Class Template Reference

#include <bslstl_simplepool.h>

Inheritance diagram for bslstl::SimplePool< VALUE, ALLOCATOR >:

Public Types

typedef VALUE ValueType
 Alias for the parameterized type VALUE.
 
typedef Types::AllocatorType AllocatorType
 
typedef Types::AllocatorTraits AllocatorTraits
 
typedef AllocatorTraits::size_type size_type
 

Public Member Functions

 SimplePool (const ALLOCATOR &allocator)
 
 SimplePool (bslmf::MovableRef< SimplePool > original)
 
 ~SimplePool ()
 
void adopt (bslmf::MovableRef< SimplePool > pool)
 
AllocatorTypeallocator ()
 
VALUE * allocate ()
 
void deallocate (void *address)
 
void reserve (size_type numBlocks)
 
void release ()
 Relinquish all memory currently allocated via this pool object.
 
void swap (SimplePool &other)
 
void quickSwapRetainAllocators (SimplePool &other)
 
void quickSwapExchangeAllocators (SimplePool &other)
 
const AllocatorTypeallocator () const
 
bool hasFreeBlocks () const
 

Detailed Description

template<class VALUE, class ALLOCATOR>
class bslstl::SimplePool< VALUE, ALLOCATOR >

This class provides methods for creating and deleting nodes using the appropriate allocator-traits of the parameterized ALLOCATOR. This type is intended to be used as a private base-class for a node-based container, in order to take advantage of the empty-base-class optimization in the case where the base-class has 0 size (as may the case if the parameterized ALLOCATOR is not a bslma::Allocator).

See bslstl_simplepool

Member Typedef Documentation

◆ AllocatorTraits

template<class VALUE , class ALLOCATOR >
typedef Types::AllocatorTraits bslstl::SimplePool< VALUE, ALLOCATOR >::AllocatorTraits

Alias for the allocator traits for the parameterized ALLOCATOR.

◆ AllocatorType

template<class VALUE , class ALLOCATOR >
typedef Types::AllocatorType bslstl::SimplePool< VALUE, ALLOCATOR >::AllocatorType

Alias for the allocator type for a bsls::AlignmentUtil::MaxAlignedType.

◆ size_type

template<class VALUE , class ALLOCATOR >
typedef AllocatorTraits::size_type bslstl::SimplePool< VALUE, ALLOCATOR >::size_type

◆ ValueType

template<class VALUE , class ALLOCATOR >
typedef VALUE bslstl::SimplePool< VALUE, ALLOCATOR >::ValueType

Constructor & Destructor Documentation

◆ SimplePool() [1/2]

template<class VALUE , class ALLOCATOR >
bslstl::SimplePool< VALUE, ALLOCATOR >::SimplePool ( const ALLOCATOR &  allocator)
inlineexplicit

Create a memory pool that returns blocks of contiguous memory of the size of the parameterized VALUE using the specified allocator to supply memory. The chunk size grows starting with at least sizeof(VALUE), doubling in size up to an implementation defined maximum number of blocks per chunk.

◆ SimplePool() [2/2]

template<class VALUE , class ALLOCATOR >
bslstl::SimplePool< VALUE, ALLOCATOR >::SimplePool ( bslmf::MovableRef< SimplePool< VALUE, ALLOCATOR > >  original)
inline

Create a memory pool, adopting all outstanding memory allocations associated with the specified original pool, that returns blocks of contiguous memory of the sizeof the paramterized VALUE using the allocator associated with original. The chunk size is set to that of original and continues to double in size up to an implementation defined maximum number of blocks per chunk. Note that original is left in a valid but unspecified state.

◆ ~SimplePool()

template<class VALUE , class ALLOCATOR >
bslstl::SimplePool< VALUE, ALLOCATOR >::~SimplePool ( )
inline

Destroy this pool, releasing all associated memory back to the underlying allocator.

Member Function Documentation

◆ adopt()

template<class VALUE , class ALLOCATOR >
void bslstl::SimplePool< VALUE, ALLOCATOR >::adopt ( bslmf::MovableRef< SimplePool< VALUE, ALLOCATOR > >  pool)
inline

Adopt all outstanding memory allocations associated with the specfied memory pool. The behavior is undefined unless this pool uses the same allocator as that associated with pool. The behavior is undefined unless this pool is in the default-constructed state.

◆ allocate()

template<class VALUE , class ALLOCATOR >
VALUE * bslstl::SimplePool< VALUE, ALLOCATOR >::allocate ( )
inline

Return the address of a block of memory of at least the size of VALUE. Note that the memory is not initialized.

◆ allocator() [1/2]

template<class VALUE , class ALLOCATOR >
SimplePool< VALUE, ALLOCATOR >::AllocatorType & bslstl::SimplePool< VALUE, ALLOCATOR >::allocator ( )
inline

Return a reference providing modifiable access to the rebound allocator traits for the node-type. Note that this operation returns a base-class (AllocatorType) reference to this object.

◆ allocator() [2/2]

template<class VALUE , class ALLOCATOR >
const SimplePool< VALUE, ALLOCATOR >::AllocatorType & bslstl::SimplePool< VALUE, ALLOCATOR >::allocator ( ) const
inline

Return a reference providing non-modifiable access to the rebound allocator traits for the node-type. Note that this operation returns a base-class (AllocatorType) reference to this object.

◆ deallocate()

template<class VALUE , class ALLOCATOR >
void bslstl::SimplePool< VALUE, ALLOCATOR >::deallocate ( void *  address)
inline

Relinquish the memory block at the specified address back to this pool object for reuse. The behavior is undefined unless address is non-zero, was allocated by this pool, and has not already been deallocated.

◆ hasFreeBlocks()

template<class VALUE , class ALLOCATOR >
bool bslstl::SimplePool< VALUE, ALLOCATOR >::hasFreeBlocks ( ) const
inline

Return true if this object holds free (currently unused) blocks, and false otherwise.

◆ quickSwapExchangeAllocators()

template<class VALUE , class ALLOCATOR >
void bslstl::SimplePool< VALUE, ALLOCATOR >::quickSwapExchangeAllocators ( SimplePool< VALUE, ALLOCATOR > &  other)
inline

Efficiently exchange the memory blocks and the allocator of this object with those of the specified other object. This method provides the no-throw exception-safety guarantee.

◆ quickSwapRetainAllocators()

template<class VALUE , class ALLOCATOR >
void bslstl::SimplePool< VALUE, ALLOCATOR >::quickSwapRetainAllocators ( SimplePool< VALUE, ALLOCATOR > &  other)
inline

Efficiently exchange the memory blocks of this object with those of the specified other object. This method provides the no-throw exception-safety guarantee. The behavior is undefined unless allocator() == other.allocator().

◆ release()

template<class VALUE , class ALLOCATOR >
void bslstl::SimplePool< VALUE, ALLOCATOR >::release ( )

◆ reserve()

template<class VALUE , class ALLOCATOR >
void bslstl::SimplePool< VALUE, ALLOCATOR >::reserve ( size_type  numBlocks)

Dynamically allocate a new chunk containing the specified numBlocks number of blocks, and add the chunk to the free memory list of this pool. The additional memory is added irrespective of the amount of free memory when called. The behavior is undefined unless 0 < numBlocks.

◆ swap()

template<class VALUE , class ALLOCATOR >
void bslstl::SimplePool< VALUE, ALLOCATOR >::swap ( SimplePool< VALUE, ALLOCATOR > &  other)
inline

Efficiently exchange the memory blocks of this object with those of the specified other object. This method provides the no-throw exception-safety guarantee. The behavior is undefined unless allocator() == other.allocator().


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