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)...); }
136 #if __TBB_CPP11_RVALUE_REF_PRESENT
147 #if _MSC_VER && !defined(__INTEL_COMPILER)
148 #pragma warning (pop)
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)
263 bytes =
self.my_size;
265 return self.my_buffer;
274 #undef __TBBMALLOC_ASSERT
#define __TBBMALLOC_ASSERT(a, 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
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
void const char const char int ITT_FORMAT __itt_group_sync p
void move(tbb_thread &t1, tbb_thread &t2)
bool operator==(const memory_pool_allocator< T, P > &a, const memory_pool_allocator< U, P > &b)
bool operator!=(const memory_pool_allocator< T, P > &a, const memory_pool_allocator< U, P > &b)
void throw_exception(exception_id eid)
Versionless convenience wrapper for throw_exception_v4()
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
void * realloc(void *ptr, size_t size)
The "realloc" analogue complementing pool_malloc.
void destroy()
destroy pool - must be called in a child class
void free(void *ptr)
The "free" analogue to discard a previously allocated piece of memory.
void recycle()
Reset pool to reuse its memory (free all objects at once)
void * malloc(size_t size)
The "malloc" analogue to allocate block of memory of size bytes.
Meets "allocator" requirements of ISO C++ Standard, Section 20.1.5.
pointer allocate(size_type n, const void *=0)
Allocate space for n objects.
const value_type & const_reference
const_pointer address(const_reference x) const
void destroy(pointer p)
Destroy value at location pointed to by p.
ptrdiff_t difference_type
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.
memory_pool_allocator(pool_type &pool)
tbb::internal::allocator_type< T >::value_type value_type
pointer address(reference x) const
void construct(pointer p, value_type &&value)
Copy-construct value at location pointed to by p.
const value_type * const_pointer
void deallocate(pointer p, size_type)
Free previously allocated block of memory.
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)
memory_pool_allocator(const memory_pool_allocator< U, P > &src)
void construct(pointer p, const value_type &value)
memory_pool_allocator< U, P > other
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)
const void * const_pointer
memory_pool_allocator(const memory_pool_allocator< U, P > &src)
memory_pool_allocator(pool_type &pool)
friend bool operator==(const memory_pool_allocator< V, R > &a, const memory_pool_allocator< U, R > &b)
memory_pool_allocator< U, P > other
Thread-safe growable pool allocator for variable-size requests.
static int deallocate_request(intptr_t pool_id, void *, size_t raw_bytes)
~memory_pool()
destroy pool
static void * allocate_request(intptr_t pool_id, size_t &bytes)
memory_pool(const Alloc &src=Alloc())
construct pool with underlying allocator
static void * allocate_request(intptr_t pool_id, size_t &bytes)
fixed_pool(void *buf, size_t size)
construct pool with underlying allocator
~fixed_pool()
destroy pool
Base class for types that should not be copied or assigned.