21 #ifndef __TBB_memory_pool_H 22 #define __TBB_memory_pool_H 24 #if !TBB_PREVIEW_MEMORY_POOL 25 #error Set TBB_PREVIEW_MEMORY_POOL to include memory_pool.h 34 #if __TBB_ALLOCATOR_CONSTRUCT_VARIADIC 39 #define __TBBMALLOC_ASSERT ASSERT 41 #define __TBBMALLOC_ASSERT(a,b) ((void)0) 45 namespace interface6 {
79 #if _MSC_VER && !defined(__INTEL_COMPILER) 81 #pragma warning (push) 82 #pragma warning (disable: 4100) 87 template<
typename T,
typename P =
internal::pool_base>
92 template<
typename U,
typename R>
94 template<
typename V,
typename U,
typename R>
96 template<
typename V,
typename U,
typename R>
132 return (
max > 0 ?
max : 1);
135 #if __TBB_ALLOCATOR_CONSTRUCT_VARIADIC 136 template<
typename U,
typename... Args>
138 { ::new((
void *)
p) U(std::forward<Args>(args)...); }
139 #else // __TBB_ALLOCATOR_CONSTRUCT_VARIADIC 140 #if __TBB_CPP11_RVALUE_REF_PRESENT 144 #endif // __TBB_ALLOCATOR_CONSTRUCT_VARIADIC 151 #if _MSC_VER && !defined(__INTEL_COMPILER) 152 #pragma warning (pop) 153 #endif // warning 4100 is back 164 template<
typename U>
struct rebind {
175 template<
typename U,
typename R>
177 template<
typename V,
typename U,
typename R>
179 template<
typename V,
typename U,
typename R>
183 template<
typename T,
typename U,
typename P>
186 template<
typename T,
typename U,
typename P>
191 template <
typename Alloc>
220 template <
typename Alloc>
223 sizeof(
typename Alloc::value_type));
224 rml::MemPoolError res = rml::pool_create_v1(intptr_t(
this), &args, &
my_pool);
225 if (res!=rml::POOL_OK)
228 template <
typename Alloc>
231 const size_t unit_size =
sizeof(
typename Alloc::value_type);
234 __TBB_TRY { ptr =
self.my_alloc.allocate( bytes/unit_size ); }
238 #if __TBB_MSVC_UNREACHABLE_CODE_IGNORED 241 #pragma warning (push) 242 #pragma warning (disable: 4702) 244 template <
typename Alloc>
247 const size_t unit_size =
sizeof(
typename Alloc::value_type);
249 self.my_alloc.deallocate( static_cast<typename Alloc::value_type*>(raw_ptr), raw_bytes/unit_size );
252 #if __TBB_MSVC_UNREACHABLE_CODE_IGNORED 253 #pragma warning (pop) 260 rml::MemPoolError res = rml::pool_create_v1(intptr_t(
this), &args, &
my_pool);
261 if (res!=rml::POOL_OK)
265 fixed_pool &
self = *reinterpret_cast<fixed_pool*>(pool_id);
267 bytes =
self.my_size;
269 return self.my_buffer;
278 #undef __TBBMALLOC_ASSERT 279 #endif// __TBB_memory_pool_H friend bool operator==(const memory_pool_allocator< V, R > &a, const memory_pool_allocator< U, R > &b)
Meets "allocator" requirements of ISO C++ Standard, Section 20.1.5.
const_pointer address(const_reference x) const
static void * allocate_request(intptr_t pool_id, size_t &bytes)
memory_pool_allocator(const memory_pool_allocator &src)
pointer address(reference x) const
Base of thread-safe pool allocator for variable-size requests.
fixed_pool(void *buf, size_t size)
construct pool with underlying allocator
void construct(pointer p, const value_type &value)
void * malloc(size_t size)
The "malloc" analogue to allocate block of memory of size bytes.
const value_type & const_reference
Base class for types that should not be copied or assigned.
Thread-safe growable pool allocator for variable-size requests.
void deallocate(pointer p, size_type)
Free previously allocated block of memory.
static int deallocate_request(intptr_t pool_id, void *, size_t raw_bytes)
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
memory_pool_allocator(const memory_pool_allocator &src)
void const char const char int ITT_FORMAT __itt_group_sync p
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.
void destroy(pointer p)
Destroy value at location pointed to by p.
bool operator!=(const memory_pool_allocator< T, P > &a, const memory_pool_allocator< U, P > &b)
void * realloc(void *ptr, size_t size)
The "realloc" analogue complementing pool_malloc.
void construct(pointer p, value_type &&value)
Copy-construct value at location pointed to by p.
memory_pool_allocator< U, P > other
memory_pool_allocator(const memory_pool_allocator< U, P > &src)
memory_pool_allocator(pool_type &pool)
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
size_type max_size() const
Largest value for which method allocate might succeed.
memory_pool_allocator< U, P > other
const value_type * const_pointer
void move(tbb_thread &t1, tbb_thread &t2)
rml::MemoryPool * my_pool
#define __TBBMALLOC_ASSERT(a, b)
memory_pool_allocator(pool_type &pool)
void recycle()
Reset pool to reuse its memory (free all objects at once)
tbb::internal::allocator_type< T >::value_type value_type
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 free(void *ptr)
The "free" analogue to discard a previously allocated piece of memory.
pointer allocate(size_type n, const void *=0)
Allocate space for n objects.
ptrdiff_t difference_type
memory_pool_allocator(const memory_pool_allocator< U, P > &src)
static void * allocate_request(intptr_t pool_id, size_t &bytes)
bool operator==(const memory_pool_allocator< T, P > &a, const memory_pool_allocator< U, P > &b)
~fixed_pool()
destroy pool
const void * const_pointer
~memory_pool()
destroy pool
void destroy()
destroy pool - must be called in a child class