Intel(R) Threading Building Blocks Doxygen Documentation
version 4.2.3
|
Go to the documentation of this file.
17 #ifndef __TBB_memory_pool_H
18 #define __TBB_memory_pool_H
20 #if !TBB_PREVIEW_MEMORY_POOL
21 #error Set TBB_PREVIEW_MEMORY_POOL to include memory_pool.h
30 #if __TBB_ALLOCATOR_CONSTRUCT_VARIADIC
35 #define __TBBMALLOC_ASSERT ASSERT
37 #define __TBBMALLOC_ASSERT(a,b) ((void)0)
41 namespace interface6 {
75 #if _MSC_VER && !defined(__INTEL_COMPILER)
77 #pragma warning (push)
78 #pragma warning (disable: 4100)
83 template<
typename T,
typename P =
internal::pool_base>
88 template<
typename U,
typename R>
90 template<
typename V,
typename U,
typename R>
92 template<
typename V,
typename U,
typename R>
128 return (
max > 0 ?
max : 1);
131 #if __TBB_ALLOCATOR_CONSTRUCT_VARIADIC
132 template<
typename U,
typename... Args>
134 { ::new((
void *)
p) U(std::forward<Args>(args)...); }
135 #else // __TBB_ALLOCATOR_CONSTRUCT_VARIADIC
136 #if __TBB_CPP11_RVALUE_REF_PRESENT
140 #endif // __TBB_ALLOCATOR_CONSTRUCT_VARIADIC
147 #if _MSC_VER && !defined(__INTEL_COMPILER)
148 #pragma warning (pop)
149 #endif // warning 4100 is back
160 template<
typename U>
struct rebind {
171 template<
typename U,
typename R>
173 template<
typename V,
typename U,
typename R>
175 template<
typename V,
typename U,
typename R>
179 template<
typename T,
typename U,
typename P>
182 template<
typename T,
typename U,
typename P>
187 template <
typename Alloc>
216 template <
typename Alloc>
219 sizeof(
typename Alloc::value_type));
220 rml::MemPoolError res = rml::pool_create_v1(intptr_t(
this), &args, &
my_pool);
221 if (res!=rml::POOL_OK)
224 template <
typename Alloc>
227 const size_t unit_size =
sizeof(
typename Alloc::value_type);
230 __TBB_TRY { ptr =
self.my_alloc.allocate( bytes/unit_size ); }
234 #if __TBB_MSVC_UNREACHABLE_CODE_IGNORED
237 #pragma warning (push)
238 #pragma warning (disable: 4702)
240 template <
typename Alloc>
243 const size_t unit_size =
sizeof(
typename Alloc::value_type);
245 self.my_alloc.deallocate( static_cast<typename Alloc::value_type*>(raw_ptr), raw_bytes/unit_size );
248 #if __TBB_MSVC_UNREACHABLE_CODE_IGNORED
249 #pragma warning (pop)
256 rml::MemPoolError res = rml::pool_create_v1(intptr_t(
this), &args, &
my_pool);
257 if (res!=rml::POOL_OK)
261 fixed_pool &
self = *reinterpret_cast<fixed_pool*>(pool_id);
263 bytes =
self.my_size;
265 return self.my_buffer;
274 #undef __TBBMALLOC_ASSERT
275 #endif// __TBB_memory_pool_H
size_type max_size() const
Largest value for which method allocate might succeed.
friend bool operator==(const memory_pool_allocator< V, R > &a, const memory_pool_allocator< U, R > &b)
memory_pool(const Alloc &src=Alloc())
construct pool with underlying allocator
void * realloc(void *ptr, size_t size)
The "realloc" analogue complementing pool_malloc.
friend bool operator!=(const memory_pool_allocator< V, R > &a, const memory_pool_allocator< U, R > &b)
ptrdiff_t difference_type
rml::MemoryPool * my_pool
void * malloc(size_t size)
The "malloc" analogue to allocate block of memory of size bytes.
const typedef void * const_pointer
static void * allocate_request(intptr_t pool_id, size_t &bytes)
void recycle()
Reset pool to reuse its memory (free all objects at once)
tbb::internal::allocator_type< T >::value_type value_type
Meets "allocator" requirements of ISO C++ Standard, Section 20.1.5.
void move(tbb_thread &t1, tbb_thread &t2)
void const char const char int ITT_FORMAT __itt_group_sync p
const_pointer address(const_reference x) const
void destroy(pointer p)
Destroy value at location pointed to by p.
memory_pool_allocator(const memory_pool_allocator &src)
#define __TBBMALLOC_ASSERT(a, b)
Base of thread-safe pool allocator for variable-size requests.
T max(const T &val1, const T &val2)
Utility template function returning greater of the two values.
static void * allocate_request(intptr_t pool_id, size_t &bytes)
memory_pool_allocator(const memory_pool_allocator &src)
memory_pool_allocator(const memory_pool_allocator< U, P > &src)
bool operator==(const memory_pool_allocator< T, P > &a, const memory_pool_allocator< U, P > &b)
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
pointer allocate(size_type n, const void *=0)
Allocate space for n objects.
memory_pool_allocator(const memory_pool_allocator< U, P > &src)
const typedef value_type * const_pointer
void destroy()
destroy pool - must be called in a child class
const typedef value_type & const_reference
memory_pool_allocator(pool_type &pool)
static int deallocate_request(intptr_t pool_id, void *, size_t raw_bytes)
void construct(pointer p, value_type &&value)
Copy-construct value at location pointed to by p.
void free(void *ptr)
The "free" analogue to discard a previously allocated piece of memory.
memory_pool_allocator< U, P > other
pointer address(reference x) const
memory_pool_allocator(pool_type &pool)
void deallocate(pointer p, size_type)
Free previously allocated block of memory.
void throw_exception(exception_id eid)
Versionless convenience wrapper for throw_exception_v4()
memory_pool_allocator< U, P > other
fixed_pool(void *buf, size_t size)
construct pool with underlying allocator
~fixed_pool()
destroy pool
~memory_pool()
destroy pool
void construct(pointer p, const value_type &value)
bool operator!=(const memory_pool_allocator< T, P > &a, const memory_pool_allocator< U, P > &b)
Base class for types that should not be copied or assigned.
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 size
Thread-safe growable pool allocator for variable-size requests.
Copyright © 2005-2019 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.