piranha  0.10
Classes | Public Types | Public Member Functions | List of all members
piranha::cache_aligning_allocator< T > Class Template Reference

Allocator that tries to align memory to the cache line size. More...

#include <piranha/cache_aligning_allocator.hpp>

Inheritance diagram for piranha::cache_aligning_allocator< T >:
Inheritance graph
[legend]
Collaboration diagram for piranha::cache_aligning_allocator< T >:
Collaboration graph
[legend]

Classes

struct  rebind
 Allocator rebind. More...
 

Public Types

using pointer = T *
 Pointer type.
 
using const_pointer = T const *
 Const pointer type.
 
using reference = T &
 Reference type.
 
using const_reference = T const &
 Const reference type.
 
using value_type = T
 Value type of the allocator. More...
 
using size_type = std::size_t
 Size type.
 
using propagate_on_container_move_assignment = std::true_type
 Move assignment propagation. More...
 

Public Member Functions

void destroy (pointer p)
 Destructor method. More...
 
template<typename U , typename... Args>
void construct (U *p, Args &&... args)
 Variadic construction method. More...
 
 cache_aligning_allocator ()
 Default constructor. More...
 
 cache_aligning_allocator (const cache_aligning_allocator &)=default
 Defaulted copy constructor.
 
 cache_aligning_allocator (cache_aligning_allocator &&)=default
 Defaulted move constructor.
 
template<typename U >
 cache_aligning_allocator (const cache_aligning_allocator< U > &other)
 Copy-constructor from different instance. More...
 
template<typename U >
 cache_aligning_allocator (cache_aligning_allocator< U > &&other)
 Move-constructor from different instance. More...
 
 ~cache_aligning_allocator ()=default
 Defaulted destructor.
 
cache_aligning_allocatoroperator= (const cache_aligning_allocator &other)=default
 Copy assignment operator. More...
 
cache_aligning_allocatoroperator= (cache_aligning_allocator &&other)=default
 Move assignment operator. More...
 
constexpr size_type max_size () const
 Maximum allocatable size. More...
 
value_typeallocate (const size_type &size) const
 Allocation function. More...
 
void deallocate (value_type *ptr, const size_type &) const
 Deallocation function. More...
 
bool operator== (const dynamic_aligning_allocator &other) const
 Equality operator. More...
 
bool operator!= (const dynamic_aligning_allocator &other) const
 Inequality operator. More...
 
std::size_t alignment () const
 Alignment getter. More...
 

Detailed Description

template<typename T>
class piranha::cache_aligning_allocator< T >

Allocator that tries to align memory to the cache line size.

This allocator will try to allocate memory aligned to the cache line size (as reported by piranha::settings).

Exception safety and move semantics are equivalent to piranha::dynamic_aligning_allocator.

Definition at line 50 of file cache_aligning_allocator.hpp.

Member Typedef Documentation

◆ propagate_on_container_move_assignment

template<typename T>
using piranha::dynamic_aligning_allocator< T >::propagate_on_container_move_assignment = std::true_type
inherited

Move assignment propagation.

This allocator has to be move assigned when the container using it is move assigned.

Definition at line 64 of file dynamic_aligning_allocator.hpp.

◆ value_type

template<typename T>
using piranha::dynamic_aligning_allocator< T >::value_type = T
inherited

Value type of the allocator.

Alias for T.

Definition at line 57 of file dynamic_aligning_allocator.hpp.

Constructor & Destructor Documentation

◆ cache_aligning_allocator() [1/3]

template<typename T>
piranha::cache_aligning_allocator< T >::cache_aligning_allocator ( )
inline

Default constructor.

Will invoke the base constructor with an alignment value determined as follows:

Definition at line 116 of file cache_aligning_allocator.hpp.

◆ cache_aligning_allocator() [2/3]

template<typename T>
template<typename U >
piranha::cache_aligning_allocator< T >::cache_aligning_allocator ( const cache_aligning_allocator< U > &  other)
inlineexplicit

Copy-constructor from different instance.

Will forward the call to the corresponding constructor in piranha::dynamic_aligning_allocator.

Parameters
otherconstruction argument.

Definition at line 130 of file cache_aligning_allocator.hpp.

◆ cache_aligning_allocator() [3/3]

template<typename T>
template<typename U >
piranha::cache_aligning_allocator< T >::cache_aligning_allocator ( cache_aligning_allocator< U > &&  other)
inlineexplicit

Move-constructor from different instance.

Will forward the call to the corresponding constructor in piranha::dynamic_aligning_allocator.

Parameters
otherconstruction argument.

Definition at line 140 of file cache_aligning_allocator.hpp.

Member Function Documentation

◆ alignment()

template<typename T>
std::size_t piranha::dynamic_aligning_allocator< T >::alignment ( ) const
inlineinherited

Alignment getter.

Returns
the alignment value used for construction.

Definition at line 183 of file dynamic_aligning_allocator.hpp.

◆ allocate()

template<typename T>
value_type* piranha::dynamic_aligning_allocator< T >::allocate ( const size_type size) const
inlineinherited

Allocation function.

The allocation function is a thin wrapper around piranha::aligned_palloc().

Parameters
sizenumber of instances of type value_type for which the space will be allocated.
Returns
a pointer to the allocated storage.
Exceptions
std::bad_allocif size is larger than max_size().
unspecifiedany exception thrown by piranha::aligned_palloc().

Definition at line 139 of file dynamic_aligning_allocator.hpp.

◆ construct()

template<typename T>
template<typename U , typename... Args>
void piranha::cache_aligning_allocator< T >::construct ( U *  p,
Args &&...  args 
)
inline

Variadic construction method.

Parameters
paddress where the object will be constructed.
argsarguments that will be forwarded for construction.

Definition at line 104 of file cache_aligning_allocator.hpp.

◆ deallocate()

template<typename T>
void piranha::dynamic_aligning_allocator< T >::deallocate ( value_type ptr,
const size_type  
) const
inlineinherited

Deallocation function.

The allocation function is a thin wrapper around piranha::aligned_pfree().

Parameters
ptra pointer to a memory block allocated via allocate().
Exceptions
unspecifiedany exception thrown by piranha::aligned_pfree().

Definition at line 155 of file dynamic_aligning_allocator.hpp.

◆ destroy()

template<typename T>
void piranha::cache_aligning_allocator< T >::destroy ( pointer  p)
inline

Destructor method.

Parameters
paddress of the object of type T to be destroyed.

Definition at line 91 of file cache_aligning_allocator.hpp.

◆ max_size()

template<typename T>
constexpr size_type piranha::dynamic_aligning_allocator< T >::max_size ( ) const
inlineinherited

Maximum allocatable size.

Returns
the maximum number of objects of type value_type that can be allocated by a single call to allocate().

Definition at line 124 of file dynamic_aligning_allocator.hpp.

◆ operator!=()

template<typename T>
bool piranha::dynamic_aligning_allocator< T >::operator!= ( const dynamic_aligning_allocator< T > &  other) const
inlineinherited

Inequality operator.

Parameters
othercomparison argument.
Returns
the opposite of operator==().

Definition at line 175 of file dynamic_aligning_allocator.hpp.

◆ operator=() [1/2]

template<typename T>
cache_aligning_allocator& piranha::cache_aligning_allocator< T >::operator= ( const cache_aligning_allocator< T > &  other)
default

Copy assignment operator.

Parameters
otherthe assignment argument.
Returns
a reference to this.

◆ operator=() [2/2]

template<typename T>
cache_aligning_allocator& piranha::cache_aligning_allocator< T >::operator= ( cache_aligning_allocator< T > &&  other)
default

Move assignment operator.

Parameters
otherthe assignment argument.
Returns
a reference to this.

◆ operator==()

template<typename T>
bool piranha::dynamic_aligning_allocator< T >::operator== ( const dynamic_aligning_allocator< T > &  other) const
inlineinherited

Equality operator.

Parameters
othercomparison argument.
Returns
true if the alignments of this and other coincide, false otherwise.

Definition at line 165 of file dynamic_aligning_allocator.hpp.


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