tbb::cache_aligned_allocator< T > Class Template Reference
Memory Allocation

Meets "allocator" requirements of ISO C++ Standard, Section 20.1.5. More...

`#include <cache_aligned_allocator.h>`

Collaboration diagram for tbb::cache_aligned_allocator< T >:

## Classes

struct | rebind

## Public Types

typedef internal::allocator_type< T >::value_type | value_type
typedef value_type * | pointer
typedef const value_type * | const_pointer
typedef value_type & | reference
typedef const value_type & | const_reference
typedef size_t | size_type
typedef ptrdiff_t | difference_type

## Public Member Functions

| cache_aligned_allocator () throw ()
| cache_aligned_allocator (const cache_aligned_allocator &) throw ()
template<typename U >
| cache_aligned_allocator (const cache_aligned_allocator< U > &) throw ()
pointer | address (reference x) const
const_pointer | address (const_reference x) const
pointer | allocate (size_type n, const void *hint=0)
| Allocate space for n objects, starting on a cache/sector line. More...
void | deallocate (pointer p, size_type)
| Free block of memory that starts on a cache line. More...
size_type | max_size () const throw ()
| Largest value for which method allocate might succeed. More...
template<typename U , typename... Args>
void | construct (U *p, Args &&... args)
| Copy-construct value at location pointed to by p. More...
void | destroy (pointer p)
| Destroy value at location pointed to by p. More...

## Detailed Description

### template<typename T>
class tbb::cache_aligned_allocator< T >

Meets "allocator" requirements of ISO C++ Standard, Section 20.1.5.

The members are ordered the same way they are in section 20.4.1 of the ISO C++ standard.

Definition at line 60 of file cache_aligned_allocator.h.

## Member Typedef Documentation

## const_pointer

template<typename T >

typedef const value_type* tbb::cache_aligned_allocator< T >::const_pointer

Definition at line 64 of file cache_aligned_allocator.h.

## const_reference

template<typename T >

typedef const value_type& tbb::cache_aligned_allocator< T >::const_reference

Definition at line 66 of file cache_aligned_allocator.h.

## difference_type

template<typename T >

typedef ptrdiff_t tbb::cache_aligned_allocator< T >::difference_type

Definition at line 68 of file cache_aligned_allocator.h.

## pointer

template<typename T >

typedef value_type* tbb::cache_aligned_allocator< T >::pointer

Definition at line 63 of file cache_aligned_allocator.h.

## reference

template<typename T >

typedef value_type& tbb::cache_aligned_allocator< T >::reference

Definition at line 65 of file cache_aligned_allocator.h.

## size_type

template<typename T >

typedef size_t tbb::cache_aligned_allocator< T >::size_type

Definition at line 67 of file cache_aligned_allocator.h.

## value_type

template<typename T >

typedef internal::allocator_type<T>::value_type tbb::cache_aligned_allocator< T >::value_type

Definition at line 62 of file cache_aligned_allocator.h.

## Constructor & Destructor Documentation

## cache_aligned_allocator() [1/3]

template<typename T >

tbb::cache_aligned_allocator< T >::cache_aligned_allocator | ( |  | ) |
throw | ( |
| ) |  |

inline

Definition at line 72 of file cache_aligned_allocator.h.

{}

## cache_aligned_allocator() [2/3]

template<typename T >

tbb::cache_aligned_allocator< T >::cache_aligned_allocator | ( | const cache_aligned_allocator< T > & |  | ) |
throw | ( |
| ) |  |

inline

Definition at line 73 of file cache_aligned_allocator.h.

{}

## cache_aligned_allocator() [3/3]

template<typename T >
template<typename U >

tbb::cache_aligned_allocator< T >::cache_aligned_allocator | ( | const cache_aligned_allocator< U > & |  | ) |
throw | ( |
| ) |  |

inline

Definition at line 74 of file cache_aligned_allocator.h.

{}

## Member Function Documentation

## address() [1/2]

template<typename T >

const_pointer tbb::cache_aligned_allocator< T >::address | ( | const_reference | x | ) | const

inline

Definition at line 77 of file cache_aligned_allocator.h.

{return &x;}

## address() [2/2]

template<typename T >

pointer tbb::cache_aligned_allocator< T >::address | ( | reference | x | ) | const

inline

Definition at line 76 of file cache_aligned_allocator.h.

{return &x;}

## allocate()

template<typename T >

pointer tbb::cache_aligned_allocator< T >::allocate | ( | size_type | n,
|  | const void * | hint = `0`
| ) |  |

inline

Allocate space for n objects, starting on a cache/sector line.

Definition at line 80 of file cache_aligned_allocator.h.

{
// The "hint" argument is always ignored in NFS_Allocate thus const_cast shouldn't hurt
return pointer(internal::NFS_Allocate( n, sizeof(value_type), const_cast<void*>(hint) ));
}
tbb::internal::NFS_Allocate
void *__TBB_EXPORTED_FUNC NFS_Allocate(size_t n_element, size_t element_size, void *hint)
Allocate memory on cache/sector line boundary.
Definition: cache_aligned_allocator.cpp:176
tbb::cache_aligned_allocator::pointer
value_type * pointer
Definition: cache_aligned_allocator.h:63
tbb::cache_aligned_allocator::value_type
internal::allocator_type< T >::value_type value_type
Definition: cache_aligned_allocator.h:62

References tbb::internal::NFS_Allocate().

Referenced by tbb::internal::concurrent_queue_iterator_base_v3::assign(), tbb::internal::concurrent_queue_base_v3::concurrent_queue_base_v3(), tbb::internal::input_buffer::grow(), tbb::internal::concurrent_queue_iterator_base_v3::initialize(), tbb::internal::rml::make_private_server(), and tbb::internal::rml::private_server::private_server().

Here is the call graph for this function:
Here is the caller graph for this function:

## construct()

template<typename T >
template<typename U , typename... Args>

void tbb::cache_aligned_allocator< T >::construct | ( | U * | p,
|  | Args &&... | args
| ) |  |

inline

Copy-construct value at location pointed to by p.

Definition at line 98 of file cache_aligned_allocator.h.

{ ::new((void *)p) U(std::forward<Args>(args)...); }
p
void const char const char int ITT_FORMAT __itt_group_sync p
Definition: ittnotify_static.h:91

References p.

## deallocate()

template<typename T >

void tbb::cache_aligned_allocator< T >::deallocate | ( | pointer | p,
|  | size_type |
| ) |  |

inline

Free block of memory that starts on a cache line.

Definition at line 86 of file cache_aligned_allocator.h.

{
internal::NFS_Free(p);
}
tbb::internal::NFS_Free
void __TBB_EXPORTED_FUNC NFS_Free(void *)
Free memory allocated by NFS_Allocate.
Definition: cache_aligned_allocator.cpp:198

References tbb::internal::NFS_Free(), and p.

Referenced by tbb::internal::concurrent_queue_iterator_base_v3::assign(), tbb::internal::input_buffer::grow(), tbb::internal::rml::private_server::remove_server_ref(), tbb::internal::concurrent_queue_base_v3::~concurrent_queue_base_v3(), tbb::internal::concurrent_queue_iterator_base_v3::~concurrent_queue_iterator_base_v3(), tbb::internal::input_buffer::~input_buffer(), and tbb::internal::rml::private_server::~private_server().

Here is the call graph for this function:
Here is the caller graph for this function:

## destroy()

template<typename T >

void tbb::cache_aligned_allocator< T >::destroy | ( | pointer | p | ) |

inline

Destroy value at location pointed to by p.

Definition at line 108 of file cache_aligned_allocator.h.

{p->~value_type();}

References p.

## max_size()

template<typename T >

size_type tbb::cache_aligned_allocator< T >::max_size | ( |  | ) | const
throw | ( |
| ) |  |

inline

Largest value for which method allocate might succeed.

Definition at line 91 of file cache_aligned_allocator.h.

{
return (~size_t(0)-internal::NFS_MaxLineSize)/sizeof(value_type);
}
tbb::internal::NFS_MaxLineSize
const size_t NFS_MaxLineSize
Compile-time constant that is upper bound on cache line/sector size.
Definition: tbb_stddef.h:216

References tbb::internal::NFS_MaxLineSize.

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

- cache_aligned_allocator.h

Copyright © 2005-2020 Intel Corporation. All Rights Reserved.

Intel, Pentium, Intel Xeon, Itanium, Intel XScale and VTune are registered trademarks or trademarks of Intel Corporation or its subsidiaries in the United States and other countries.

* Other names and brands may be claimed as the property of others.