Embedded Multicore Building Blocks V1.0.0
Classes | Public Types | Public Member Functions | List of all members
embb::base::AllocatorCacheAligned< Type > Class Template Reference

Allocator according to the C++ standard. More...

#include <memory_allocation.h>

Classes

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

Public Types

typedef size_t size_type
 Quantity of elements type. More...
 
typedef ptrdiff_t difference_type
 Difference between two pointers type. More...
 
typedef Type * pointer
 Pointer to element type. More...
 
typedef const Type * const_pointer
 Pointer to constant element type. More...
 
typedef Type & reference
 Reference to element type. More...
 
typedef const Type & const_reference
 Reference to constant element type. More...
 
typedef Type value_type
 Element type. More...
 

Public Member Functions

 AllocatorCacheAligned () throw ()
 Constructs allocator object. More...
 
 AllocatorCacheAligned (const AllocatorCacheAligned &a) throw ()
 Copies allocator object. More...
 
template<typename OtherType >
 AllocatorCacheAligned (const AllocatorCacheAligned< OtherType > &) throw ()
 Constructs allocator object. More...
 
 ~AllocatorCacheAligned () throw ()
 Destructs allocator object. More...
 
pointer allocate (size_type n, const void *=0)
 Allocates but doesn't initialize storage for elements of type Type. More...
 
void deallocate (pointer p, size_type)
 Deallocates storage of destroyed elements. More...
 
pointer address (reference x) const
 Gets address of an object. More...
 
const_pointer address (const_reference x) const
 Gets address of a constant object. More...
 
size_type max_size () const throw ()
 Allocation maximum More...
 
void construct (pointer p, const value_type &val)
 Initializes elements of allocated storage with specified value. More...
 
void destroy (pointer p)
 Destroys elements of initialized storage. More...
 

Detailed Description

template<typename Type>
class embb::base::AllocatorCacheAligned< Type >

Allocator according to the C++ standard.

Allocates memory cache-aligned.

For memory allocation and deallocation, embb::base::Allocation::AllocateCacheAligned() and embb::base::Allocation::FreeAligned() are used, respectively.

In debug mode, leak checking is active. The function embb::base::Allocation::AllocatedBytes() returns the number of currently allocated bytes.

Member Typedef Documentation

template<typename Type>
typedef size_t embb::base::AllocatorCacheAligned< Type >::size_type

Quantity of elements type.

template<typename Type>
typedef ptrdiff_t embb::base::AllocatorCacheAligned< Type >::difference_type

Difference between two pointers type.

template<typename Type>
typedef Type* embb::base::AllocatorCacheAligned< Type >::pointer

Pointer to element type.

template<typename Type>
typedef const Type* embb::base::AllocatorCacheAligned< Type >::const_pointer

Pointer to constant element type.

template<typename Type>
typedef Type& embb::base::AllocatorCacheAligned< Type >::reference

Reference to element type.

template<typename Type>
typedef const Type& embb::base::AllocatorCacheAligned< Type >::const_reference

Reference to constant element type.

template<typename Type>
typedef Type embb::base::AllocatorCacheAligned< Type >::value_type

Element type.

Constructor & Destructor Documentation

template<typename Type>
embb::base::AllocatorCacheAligned< Type >::AllocatorCacheAligned ( )
throw (
)

Constructs allocator object.

template<typename Type>
embb::base::AllocatorCacheAligned< Type >::AllocatorCacheAligned ( const AllocatorCacheAligned< Type > &  a)
throw (
)

Copies allocator object.

Parameters
[in]aOther allocator object
template<typename Type>
template<typename OtherType >
embb::base::AllocatorCacheAligned< Type >::AllocatorCacheAligned ( const AllocatorCacheAligned< OtherType > &  )
throw (
)

Constructs allocator object.

Allows construction from allocators for different types (rebind)

template<typename Type>
embb::base::AllocatorCacheAligned< Type >::~AllocatorCacheAligned ( )
throw (
)

Destructs allocator object.

Member Function Documentation

template<typename Type>
pointer embb::base::AllocatorCacheAligned< Type >::allocate ( size_type  n,
const void *  = 0 
)

Allocates but doesn't initialize storage for elements of type Type.

Concurrency
Thread-safe
Returns
Pointer to allocated storage
Dynamic memory allocation
see Allocation::Allocate()
Parameters
[in]nNumber of elements to allocate
template<typename Type>
void embb::base::AllocatorCacheAligned< Type >::deallocate ( pointer  p,
size_type   
)

Deallocates storage of destroyed elements.

Concurrency
Thread-safe
Parameters
[in,out]pPointer to allocated storage
template<typename Type>
pointer embb::base::Allocator< Type >::address ( reference  x) const
inherited

Gets address of an object.

Returns
Address of object
Concurrency
Thread-safe and wait-free
Parameters
xReference to object
template<typename Type>
const_pointer embb::base::Allocator< Type >::address ( const_reference  x) const
inherited

Gets address of a constant object.

Returns
Address of object
Concurrency
Thread-safe and wait-free
Parameters
xReference to constant object
template<typename Type>
size_type embb::base::Allocator< Type >::max_size ( ) const
throw (
)
inherited

Allocation maximum

Returns
Maximum number of elements that can be allocated
Concurrency
Thread-safe and wait-free
template<typename Type>
void embb::base::Allocator< Type >::construct ( pointer  p,
const value_type val 
)
inherited

Initializes elements of allocated storage with specified value.

Concurrency
Thread-safe
Parameters
pPointer to allocated storage
valValue
template<typename Type>
void embb::base::Allocator< Type >::destroy ( pointer  p)
inherited

Destroys elements of initialized storage.

Concurrency
Thread-safe
Parameters
pPointer to allocated storage