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