0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Types | Public Member Functions | Private Types | Private Attributes | List of all members
Hypertable::ArenaAllocatorBase< T, ArenaT > Class Template Reference

Specialized Allocator class using a Memory Arena which manages the allocated memory; see PageArenaAllocator.h for an actual implementation. More...

#include <Allocator.h>

Inheritance diagram for Hypertable::ArenaAllocatorBase< T, ArenaT >:
Inheritance graph
[legend]
Collaboration diagram for Hypertable::ArenaAllocatorBase< T, ArenaT >:
Collaboration graph
[legend]

Public Types

typedef Base::pointer pointer
 
typedef Base::size_type size_type
 
- Public Types inherited from Hypertable::AllocatorBase< T >
typedef size_t size_type
 
typedef ptrdiff_t difference_type
 
typedef T * pointer
 
typedef const T * const_pointer
 
typedef T & reference
 
typedef const T & const_reference
 
typedef T value_type
 

Public Member Functions

 ArenaAllocatorBase ()
 Default constructor; creates an empty object. More...
 
 ArenaAllocatorBase (ArenaT &arena)
 Constructor; takes ownership of a pointer to a memory arena. More...
 
template<typename U >
 ArenaAllocatorBase (const ArenaAllocatorBase< U, ArenaT > &copy)
 Copy Constructor; copies the memory arena. More...
 
void check_allocate_size (size_type sz) const
 Sanity check the size of the requested buffer; if it's too large then most likely this is a bug in the application. More...
 
pointer default_allocate (size_type sz)
 Allocate an array of objects using the regular operator new. More...
 
void deallocate (pointer p, size_type sz)
 Deletes allocated objects unless an Arena Allocator was used (in this case the function is a nop) More...
 
template<typename U >
bool operator== (const ArenaAllocatorBase< U, ArenaT > &x) const
 operator == returns true if the arena pointers are equal More...
 
template<typename U >
bool operator!= (const ArenaAllocatorBase< U, ArenaT > &x) const
 operator != returns true if the arena pointers are not equal More...
 
template<typename U >
void swap (ArenaAllocatorBase< U, ArenaT > &other)
 Swaps the memory arena from another allocator with the arena of 'this' allocator. More...
 
ArenaT * arena () const
 Returns a pointer to the Arena. More...
 
void set_arena (ArenaT *arena)
 Sets the Arena pointer. More...
 
- Public Member Functions inherited from Hypertable::AllocatorBase< T >
pointer address (reference x) const
 Returns a pointer to an object of type T. More...
 
const_pointer address (const_reference x) const
 Returns a const pointer to an object of type T. More...
 
size_type max_size () const throw ()
 Returns the maximum number of objects that this Allocator can allocate; used to check for bad allocations. More...
 
template<class U , class... Args>
void construct (U *p, Args &&...args)
 Creates a new object instance using placement new and the copy constructor. More...
 
void construct (pointer p)
 Creates a new object instance using placement new and the default constructor. More...
 
void destroy (pointer p)
 Calls the destructor of an object (unless it's a POD) More...
 

Private Types

typedef AllocatorBase< T > Base
 

Private Attributes

ArenaT * m_arenap
 

Detailed Description

template<typename T, class ArenaT>
class Hypertable::ArenaAllocatorBase< T, ArenaT >

Specialized Allocator class using a Memory Arena which manages the allocated memory; see PageArenaAllocator.h for an actual implementation.

Definition at line 159 of file Allocator.h.

Member Typedef Documentation

template<typename T, class ArenaT>
typedef AllocatorBase<T> Hypertable::ArenaAllocatorBase< T, ArenaT >::Base
private

Definition at line 160 of file Allocator.h.

template<typename T, class ArenaT>
typedef Base::pointer Hypertable::ArenaAllocatorBase< T, ArenaT >::pointer

Definition at line 165 of file Allocator.h.

template<typename T, class ArenaT>
typedef Base::size_type Hypertable::ArenaAllocatorBase< T, ArenaT >::size_type

Definition at line 166 of file Allocator.h.

Constructor & Destructor Documentation

template<typename T, class ArenaT>
Hypertable::ArenaAllocatorBase< T, ArenaT >::ArenaAllocatorBase ( )
inline

Default constructor; creates an empty object.

Definition at line 169 of file Allocator.h.

template<typename T, class ArenaT>
Hypertable::ArenaAllocatorBase< T, ArenaT >::ArenaAllocatorBase ( ArenaT &  arena)
inline

Constructor; takes ownership of a pointer to a memory arena.

Definition at line 172 of file Allocator.h.

template<typename T, class ArenaT>
template<typename U >
Hypertable::ArenaAllocatorBase< T, ArenaT >::ArenaAllocatorBase ( const ArenaAllocatorBase< U, ArenaT > &  copy)
inline

Copy Constructor; copies the memory arena.

Definition at line 176 of file Allocator.h.

Member Function Documentation

template<typename T, class ArenaT>
ArenaT* Hypertable::ArenaAllocatorBase< T, ArenaT >::arena ( ) const
inline

Returns a pointer to the Arena.

Returns
Pointer to this allocator's arena; can be NULL

Definition at line 246 of file Allocator.h.

template<typename T, class ArenaT>
void Hypertable::ArenaAllocatorBase< T, ArenaT >::check_allocate_size ( size_type  sz) const
inline

Sanity check the size of the requested buffer; if it's too large then most likely this is a bug in the application.

Parameters
szSize of the requested buffer
Exceptions
Error::BAD_MEMORY_ALLOCATIONIf the size is too large

Definition at line 188 of file Allocator.h.

template<typename T, class ArenaT>
void Hypertable::ArenaAllocatorBase< T, ArenaT >::deallocate ( pointer  p,
size_type  sz 
)
inline

Deletes allocated objects unless an Arena Allocator was used (in this case the function is a nop)

Parameters
pPointer to the object
szUnused parameter, ignored

Definition at line 210 of file Allocator.h.

template<typename T, class ArenaT>
pointer Hypertable::ArenaAllocatorBase< T, ArenaT >::default_allocate ( size_type  sz)
inline

Allocate an array of objects using the regular operator new.

Parameters
szNumber of elements in the allocated array
Returns
A pointer to the allocated array

Definition at line 199 of file Allocator.h.

template<typename T, class ArenaT>
template<typename U >
bool Hypertable::ArenaAllocatorBase< T, ArenaT >::operator!= ( const ArenaAllocatorBase< U, ArenaT > &  x) const
inline

operator != returns true if the arena pointers are not equal

Parameters
xConstant reference to the other object

Definition at line 226 of file Allocator.h.

template<typename T, class ArenaT>
template<typename U >
bool Hypertable::ArenaAllocatorBase< T, ArenaT >::operator== ( const ArenaAllocatorBase< U, ArenaT > &  x) const
inline

operator == returns true if the arena pointers are equal

Parameters
xConstant reference to the other object

Definition at line 217 of file Allocator.h.

template<typename T, class ArenaT>
void Hypertable::ArenaAllocatorBase< T, ArenaT >::set_arena ( ArenaT *  arena)
inline

Sets the Arena pointer.

Parameters
arenaPointer to the arena allocator

Definition at line 252 of file Allocator.h.

template<typename T, class ArenaT>
template<typename U >
void Hypertable::ArenaAllocatorBase< T, ArenaT >::swap ( ArenaAllocatorBase< U, ArenaT > &  other)
inline

Swaps the memory arena from another allocator with the arena of 'this' allocator.

Parameters
otherThe other ArenaAllocatorBase object

Definition at line 236 of file Allocator.h.

Member Data Documentation

template<typename T, class ArenaT>
ArenaT* Hypertable::ArenaAllocatorBase< T, ArenaT >::m_arenap
private

Definition at line 162 of file Allocator.h.


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