Intel(R) Threading Building Blocks Doxygen Documentation  version 4.2.3
tbb::tbb_allocator< T > Class Template Reference

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

#include <tbb_allocator.h>

Inheritance diagram for tbb::tbb_allocator< T >:
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_typepointer
 
typedef value_typereference
 
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...
 
void construct (pointer p, value_type &&value)
 Copy-construct value at location pointed to by p. More...
 
void construct (pointer p, const value_type &value)
 
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_typeconst_pointer
 
const typedef value_typeconst_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.

72  {
73  scalable,
74  standard
75  };

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.

77 {}

◆ 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.

78 {}

◆ 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.

79 {}

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.

82 {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.

81 {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.

85  {
87  }

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 ( )
inlinestatic

Returns current allocator.

Definition at line 116 of file tbb_allocator.h.

116  {
118  }

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() [1/2]

template<typename T >
void tbb::tbb_allocator< T >::construct ( pointer  p,
const value_type value 
)
inline

Definition at line 109 of file tbb_allocator.h.

109 {::new((void*)(p)) value_type(value);}

References p, and value.

◆ construct() [2/2]

template<typename T >
void tbb::tbb_allocator< T >::construct ( pointer  p,
value_type &&  value 
)
inline

Copy-construct value at location pointed to by p.

Definition at line 107 of file tbb_allocator.h.

107 {::new((void*)(p)) value_type(std::move(value));}

References tbb::move(), p, and value.

Here is the call graph for this function:

◆ 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.

90  {
92  }

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.

113 {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.

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

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::tbb_allocator::size_type
size_t size_type
Definition: tbb_allocator.h:65
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
@ standard
Definition: tbb_allocator.h:74
tbb::move
void move(tbb_thread &t1, tbb_thread &t2)
Definition: tbb_thread.h:319
tbb::tbb_allocator::value_type
internal::allocator_type< T >::value_type value_type
Definition: tbb_allocator.h:60
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::tbb_allocator::pointer
value_type * pointer
Definition: tbb_allocator.h:61
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
tbb::tbb_allocator::scalable
@ scalable
Definition: tbb_allocator.h:73
value
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp __itt_timestamp ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain ITT_FORMAT p const __itt_domain __itt_string_handle unsigned long long value
Definition: ittnotify_static.h:192
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.