21 #ifndef __TBB_tbb_allocator_H 22 #define __TBB_tbb_allocator_H 24 #include "tbb_stddef.h" 26 #if __TBB_ALLOCATOR_CONSTRUCT_VARIADIC 30 #if !TBB_USE_EXCEPTIONS && _MSC_VER 32 #pragma warning (push) 33 #pragma warning (disable: 4530) 38 #if !TBB_USE_EXCEPTIONS && _MSC_VER 49 void __TBB_EXPORTED_FUNC deallocate_via_handler_v3(
void *p );
53 void* __TBB_EXPORTED_FUNC allocate_via_handler_v3(
size_t n );
56 bool __TBB_EXPORTED_FUNC is_malloc_used_v3();
60 #if _MSC_VER && !defined(__INTEL_COMPILER) 62 #pragma warning (push) 63 #pragma warning (disable: 4100) 75 typedef typename internal::allocator_type<T>::value_type value_type;
76 typedef value_type* pointer;
77 typedef const value_type* const_pointer;
78 typedef value_type& reference;
79 typedef const value_type& const_reference;
80 typedef size_t size_type;
81 typedef ptrdiff_t difference_type;
96 pointer address(reference x)
const {
return &x;}
97 const_pointer address(const_reference x)
const {
return &x;}
101 return pointer(internal::allocate_via_handler_v3( n *
sizeof(value_type) ));
106 internal::deallocate_via_handler_v3(p);
111 size_type max =
static_cast<size_type
>(-1) /
sizeof (value_type);
112 return (max > 0 ? max : 1);
116 #if __TBB_ALLOCATOR_CONSTRUCT_VARIADIC 117 template<
typename U,
typename... Args>
118 void construct(U *p, Args&&... args)
119 { ::new((
void *)p) U(std::forward<Args>(args)...); }
120 #else // __TBB_ALLOCATOR_CONSTRUCT_VARIADIC 121 #if __TBB_CPP11_RVALUE_REF_PRESENT 122 void construct( pointer p, value_type&& value ) {::new((
void*)(p)) value_type(std::move(value));}
124 void construct( pointer p,
const value_type& value ) {::new((
void*)(p)) value_type(value);}
125 #endif // __TBB_ALLOCATOR_CONSTRUCT_VARIADIC 132 return internal::is_malloc_used_v3() ? standard : scalable;
136 #if _MSC_VER && !defined(__INTEL_COMPILER) 137 #pragma warning (pop) 138 #endif // warning 4100 is back 145 typedef void* pointer;
146 typedef const void* const_pointer;
147 typedef void value_type;
148 template<
typename U>
struct rebind {
153 template<
typename T,
typename U>
156 template<
typename T,
typename U>
165 template <
typename T,
template<
typename X>
class Allocator =
tbb_allocator>
169 typedef Allocator<T> base_allocator_type;
170 typedef typename base_allocator_type::value_type value_type;
171 typedef typename base_allocator_type::pointer pointer;
172 typedef typename base_allocator_type::const_pointer const_pointer;
173 typedef typename base_allocator_type::reference reference;
174 typedef typename base_allocator_type::const_reference const_reference;
175 typedef typename base_allocator_type::size_type size_type;
176 typedef typename base_allocator_type::difference_type difference_type;
186 pointer allocate(
const size_type n,
const void *hint = 0 ) {
187 pointer ptr = base_allocator_type::allocate( n, hint );
188 std::memset( ptr, 0, n *
sizeof(value_type) );
195 template<
template<
typename T>
class Allocator>
198 typedef Allocator<void> base_allocator_type;
199 typedef typename base_allocator_type::value_type value_type;
200 typedef typename base_allocator_type::pointer pointer;
201 typedef typename base_allocator_type::const_pointer const_pointer;
202 template<
typename U>
struct rebind {
207 template<
typename T1,
template<
typename X1>
class B1,
typename T2,
template<
typename X2>
class B2>
209 return static_cast< B1<T1>
>(a) ==
static_cast< B2<T2>
>(b);
211 template<
typename T1,
template<
typename X1>
class B1,
typename T2,
template<
typename X2>
class B2>
213 return static_cast< B1<T1>
>(a) !=
static_cast< B2<T2>
>(b);
Meets "allocator" requirements of ISO C++ Standard, Section 20.1.5.
Definition: tbb_allocator.h:166
malloc_type
Specifies current allocator.
Definition: tbb_allocator.h:87
Definition: tbb_allocator.h:82
size_type max_size() const
Largest value for which method allocate might succeed.
Definition: tbb_allocator.h:110
pointer allocate(size_type n, const void *=0)
Allocate space for n objects.
Definition: tbb_allocator.h:100
Definition: _flow_graph_async_msg_impl.h:32
void deallocate(pointer p, size_type)
Free previously allocated block of memory.
Definition: tbb_allocator.h:105
The namespace tbb contains all components of the library.
Definition: parallel_for.h:44
Meets "allocator" requirements of ISO C++ Standard, Section 20.1.5.
Definition: tbb_allocator.h:73
void destroy(pointer p)
Destroy value at location pointed to by p.
Definition: tbb_allocator.h:128
Definition: tbb_allocator.h:177
void construct(pointer p, const value_type &value)
Copy-construct value at location pointed to by p.
Definition: tbb_allocator.h:124
static malloc_type allocator_type()
Returns current allocator.
Definition: tbb_allocator.h:131