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 {
62 return rml::pool_realloc(
my_pool, ptr, size);
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>
190 static void *allocate_request(intptr_t pool_id,
size_t & bytes);
191 static int deallocate_request(intptr_t pool_id,
void*,
size_t raw_bytes);
205 inline static void *allocate_request(intptr_t pool_id,
size_t & bytes);
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)
263 bytes =
self.my_size;
265 return self.my_buffer;
274 #undef __TBBMALLOC_ASSERT
275 #endif// __TBB_memory_pool_H
const void * const_pointer
void throw_exception(exception_id eid)
Versionless convenience wrapper for throw_exception_v4()
memory_pool_allocator(const memory_pool_allocator &src)
friend bool operator!=(const memory_pool_allocator< V, R > &a, const memory_pool_allocator< U, R > &b)
size_type max_size() const
Largest value for which method allocate might succeed.
void * malloc(size_t size)
The "malloc" analogue to allocate block of memory of size bytes.
Base class for types that should not be copied or assigned.
void destroy(pointer p)
Destroy value at location pointed to by p.
void deallocate(pointer p, size_type)
Free previously allocated block of memory.
memory_pool_allocator(const memory_pool_allocator< U, P > &src)
memory_pool(const Alloc &src=Alloc())
construct pool with underlying allocator
memory_pool_allocator(pool_type &pool)
memory_pool_allocator(const memory_pool_allocator< U, P > &src)
friend bool operator==(const memory_pool_allocator< V, R > &a, const memory_pool_allocator< U, R > &b)
void move(tbb_thread &t1, tbb_thread &t2)
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
#define __TBBMALLOC_ASSERT(a, b)
fixed_pool(void *buf, size_t size)
construct pool with underlying allocator
static void * allocate_request(intptr_t pool_id, size_t &bytes)
static int deallocate_request(intptr_t pool_id, void *, size_t raw_bytes)
~memory_pool()
destroy pool
memory_pool_allocator(pool_type &pool)
~fixed_pool()
destroy pool
void construct(pointer p, value_type &&value)
Copy-construct value at location pointed to by p.
static void * allocate_request(intptr_t pool_id, size_t &bytes)
pointer allocate(size_type n, const void *=0)
Allocate space for n objects.
ptrdiff_t difference_type
void recycle()
Reset pool to reuse its memory (free all objects at once)
Meets "allocator" requirements of ISO C++ Standard, Section 20.1.5.
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
void const char const char int ITT_FORMAT __itt_group_sync p
T max(const T &val1, const T &val2)
Utility template function returning greater of the two values.
Base of thread-safe pool allocator for variable-size requests.
rml::MemoryPool * my_pool
pointer address(reference x) const
const value_type & const_reference
void construct(pointer p, const value_type &value)
tbb::internal::allocator_type< T >::value_type value_type
memory_pool_allocator< U, P > other
void destroy()
destroy pool - must be called in a child class
memory_pool_allocator< U, P > other
void * realloc(void *ptr, size_t size)
The "realloc" analogue complementing pool_malloc.
const_pointer address(const_reference x) const
const value_type * const_pointer
memory_pool_allocator(const memory_pool_allocator &src)
Thread-safe growable pool allocator for variable-size requests.
void free(void *ptr)
The "free" analogue to discard a previously allocated piece of memory.