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

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

`#include <tbb_allocator.h>`

Collaboration diagram for tbb::tbb_allocator< T >:

## Classes

struct | rebind

## Public Types

enum | malloc_type { scalable, standard }
| Specifies current allocator. More...
typedef internal::allocator_type< T >::value_type | value_type
typedef value_type * | pointer
typedef value_type & | reference
typedef size_t | size_type
typedef ptrdiff_t | difference_type

## Public Member Functions

| tbb_allocator () throw ()
| tbb_allocator (const tbb_allocator &) throw ()
template<typename U >
| tbb_allocator (const tbb_allocator< U > &) throw ()
pointer | address (reference x) const
const_pointer | address (const_reference x) const
pointer | allocate (size_type n, const void *=0)
| Allocate space for n objects. More...
void | deallocate (pointer p, size_type)
| Free previously allocated block of memory. 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...

## Static Public Member Functions

static malloc_type | allocator_type ()
| Returns current allocator. More...

## Public Attributes

const typedef value_type * | const_pointer
const typedef value_type & | const_reference

## Detailed Description

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

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

The class selects the best memory allocation mechanism available from scalable_malloc and standard malloc. The members are ordered the same way they are in section 20.4.1 of the ISO C++ standard.

Definition at line 58 of file tbb_allocator.h.

## Member Typedef Documentation

## difference_type

template<typename T >

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

Definition at line 66 of file tbb_allocator.h.

## pointer

template<typename T >

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

Definition at line 61 of file tbb_allocator.h.

## reference

template<typename T >

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

Definition at line 63 of file tbb_allocator.h.

## size_type

template<typename T >

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

Definition at line 65 of file tbb_allocator.h.

## value_type

template<typename T >

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

Definition at line 60 of file tbb_allocator.h.

## Member Enumeration Documentation

## malloc_type

template<typename T >

enum tbb::tbb_allocator::malloc_type

Specifies current allocator.

Enumerator
scalable |
standard |

Definition at line 72 of file tbb_allocator.h.

{
scalable,
standard
};

## Constructor & Destructor Documentation

## tbb_allocator() [1/3]

template<typename T >

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

inline

Definition at line 77 of file tbb_allocator.h.

{}

## tbb_allocator() [2/3]

template<typename T >

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

inline

Definition at line 78 of file tbb_allocator.h.

{}

## tbb_allocator() [3/3]

template<typename T >
template<typename U >

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

inline

Definition at line 79 of file tbb_allocator.h.

{}

## Member Function Documentation

## address() [1/2]

template<typename T >

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

inline

Definition at line 82 of file tbb_allocator.h.

{return &x;}

## address() [2/2]

template<typename T >

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

inline

Definition at line 81 of file tbb_allocator.h.

{return &x;}

## allocate()

template<typename T >

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

inline

Allocate space for n objects.

Definition at line 85 of file tbb_allocator.h.

{
return pointer(internal::allocate_via_handler_v3( n * sizeof(value_type) ));
}

References tbb::internal::allocate_via_handler_v3().

Referenced by tbb::interface6::internal::token_helper< T, true >::create_token().

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

## allocator_type()

template<typename T >

static malloc_type tbb::tbb_allocator< T >::allocator_type | ( |  | ) |

inline static

Returns current allocator.

Definition at line 116 of file tbb_allocator.h.

{
return internal::is_malloc_used_v3() ? standard : scalable;
}

References tbb::internal::is_malloc_used_v3(), tbb::tbb_allocator< T >::scalable, and tbb::tbb_allocator< T >::standard.

Here is the call graph for this function:

## construct()

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

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

inline

Copy-construct value at location pointed to by p.

Definition at line 103 of file tbb_allocator.h.

{ ::new((void *)p) U(std::forward<Args>(args)...); }

References p.

## deallocate()

template<typename T >

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

inline

Free previously allocated block of memory.

Definition at line 90 of file tbb_allocator.h.

{
internal::deallocate_via_handler_v3(p);
}

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

Referenced by tbb::interface6::internal::token_helper< T, true >::destroy_token().

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

## destroy()

template<typename T >

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

inline

Destroy value at location pointed to by p.

Definition at line 113 of file tbb_allocator.h.

{p->~value_type();}

References p.

Referenced by tbb::interface6::internal::token_helper< T, true >::destroy_token().

Here is the caller graph for this function:

## max_size()

template<typename T >

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

inline

Largest value for which method allocate might succeed.

Definition at line 95 of file tbb_allocator.h.

{
size_type max = static_cast<size_type>(-1) / sizeof (value_type);
return (max > 0 ? max : 1);
}

References tbb::internal::max().

Here is the call graph for this function:

## Member Data Documentation

## const_pointer

template<typename T >

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

Definition at line 62 of file tbb_allocator.h.

## const_reference

template<typename T >

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

Definition at line 64 of file tbb_allocator.h.

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

- tbb_allocator.h

tbb::internal::deallocate_via_handler_v3
void __TBB_EXPORTED_FUNC deallocate_via_handler_v3(void *p)
Deallocates memory using FreeHandler.
Definition: cache_aligned_allocator.cpp:232
tbb::tbb_allocator::standard
Definition: tbb_allocator.h:74
tbb::tbb_allocator::value_type
internal::allocator_type< T >::value_type value_type
Definition: tbb_allocator.h:60
tbb::tbb_allocator::pointer
value_type * pointer
Definition: tbb_allocator.h:61
tbb::tbb_allocator::scalable
Definition: tbb_allocator.h:73
tbb::tbb_allocator::size_type
size_t size_type
Definition: tbb_allocator.h:65
tbb::internal::allocate_via_handler_v3
void *__TBB_EXPORTED_FUNC allocate_via_handler_v3(size_t n)
Allocates memory using MallocHandler.
Definition: cache_aligned_allocator.cpp:224
tbb::internal::max
T max(const T &val1, const T &val2)
Utility template function returning greater of the two values.
Definition: tbb_misc.h:119
p
void const char const char int ITT_FORMAT __itt_group_sync p
Definition: ittnotify_static.h:91
tbb::internal::is_malloc_used_v3
bool __TBB_EXPORTED_FUNC is_malloc_used_v3()
Returns true if standard malloc/free are used to work with memory.
Definition: cache_aligned_allocator.cpp:238

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.