commons::region_alloc< T > Class Template Reference

Standard region-based allocator. More...

#include <region.h>

Collaboration diagram for commons::region_alloc< T >:

Collaboration graph
[legend]

List of all members.

Public Types

typedef T value_type
typedef T * pointer
typedef const T * const_pointer
typedef T & reference
typedef const T & const_reference
typedef std::size_t size_type
typedef std::ptrdiff_t difference_type
typedef mem_region pool_type

Public Member Functions

pointer address (reference value) const
 Return address of values.
const_pointer address (const_reference value) const
 region_alloc () throw ()
 Default constructor creates a new pool.
 region_alloc (const region_alloc &src) throw ()
 Copy constructor addrefs the region.
template<class U>
 region_alloc (const region_alloc< U > &src) throw ()
 Copy constructor addrefs the region.
 ~region_alloc () throw ()
 Destructor decrefs the region.
size_type max_size () const throw ()
 Return maximum number of elements that can be allocated.
pointer allocate (size_type num, const void *=0)
 Allocate (but don't initialize) num elements of type T.
void construct (pointer p, const T &value)
 Initialize elements of allocated storage p with value `value` using placement new.
void destroy (pointer p)
 Destroy elements of initialized storage p by calling their destructor.
void deallocate (pointer p, size_type num)
 Deallocate storage p of deleted elements.

Public Attributes

pool_typeregion

Classes

struct  rebind
 Rebind allocator to type U. More...


Detailed Description

template<class T>
class commons::region_alloc< T >

Standard region-based allocator.

Useful for restricting locality and/or avoiding multithreaded contention.

Definition at line 103 of file region.h.


Constructor & Destructor Documentation

template<class T>
commons::region_alloc< T >::region_alloc ( const region_alloc< T > &  src  )  throw () [inline]

Copy constructor addrefs the region.

TODO: This is in fact highly necessary. Understand why. Understand both the following ctors.

Definition at line 143 of file region.h.

References commons::mem_region::addref().

00143                                                   {
00144       region = src.region;
00145       region->addref();
00146     }

Here is the call graph for this function:


Member Function Documentation

template<class T>
size_type commons::region_alloc< T >::max_size (  )  const throw () [inline]

Return maximum number of elements that can be allocated.

Simply return the size based on the size of memory.

Definition at line 166 of file region.h.

00167     {
00168       return numeric_limits<size_t>::max() / sizeof(T);
00169     }

template<class T>
void commons::region_alloc< T >::deallocate ( pointer  p,
size_type  num 
) [inline]

Deallocate storage p of deleted elements.

This actually does nothing.

Definition at line 195 of file region.h.

00195 {}


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

Generated on Mon Mar 2 22:13:23 2009 for C++ Commons by  doxygen 1.5.6