tbb::interface6::memory_pool_allocator< T, P > Class Template Reference
Memory Allocation

Meets "allocator" requirements of ISO C++ Standard, Section 20.1.5. More...

`#include <memory_pool.h>`

Collaboration diagram for tbb::interface6::memory_pool_allocator< T, P >:

## Classes

struct | rebind

## Public Types

typedef tbb::internal::allocator_type< T >::value_type | value_type
typedef value_type * | pointer
typedef const value_type * | const_pointer
typedef value_type & | reference
typedef const value_type & | const_reference
typedef size_t | size_type
typedef ptrdiff_t | difference_type

## Public Member Functions

| memory_pool_allocator (pool_type &pool) throw ()
| memory_pool_allocator (const memory_pool_allocator &src) throw ()
template<typename U >
| memory_pool_allocator (const memory_pool_allocator< U, P > &src) throw ()
pointer | address (reference x) const
const_pointer | address (const_reference x) const
pointer | allocate (size_type n, const void *=0)
| Allocate space for n objects. More...
void | deallocate (pointer p, size_type)
| Free previously allocated block of memory. More...
size_type | max_size () const throw ()
| Largest value for which method allocate might succeed. More...
void | construct (pointer p, value_type &&value)
| Copy-construct value at location pointed to by p. More...
void | construct (pointer p, const value_type &value)
void | destroy (pointer p)
| Destroy value at location pointed to by p. More...

## Protected Types

typedef P | pool_type

## Protected Attributes

pool_type * | my_pool

## Friends

template<typename U , typename R >
class | memory_pool_allocator
template<typename V , typename U , typename R >
bool | operator== (const memory_pool_allocator< V, R > &a, const memory_pool_allocator< U, R > &b)
template<typename V , typename U , typename R >
bool | operator!= (const memory_pool_allocator< V, R > &a, const memory_pool_allocator< U, R > &b)

## Detailed Description

### template<typename T, typename P = internal::pool_base>
class tbb::interface6::memory_pool_allocator< T, P >

Meets "allocator" requirements of ISO C++ Standard, Section 20.1.5.

Definition at line 84 of file memory_pool.h.

## Member Typedef Documentation

## const_pointer

template<typename T , typename P = internal::pool_base>

typedef const value_type* tbb::interface6::memory_pool_allocator< T, P >::const_pointer

Definition at line 97 of file memory_pool.h.

## const_reference

template<typename T , typename P = internal::pool_base>

typedef const value_type& tbb::interface6::memory_pool_allocator< T, P >::const_reference

Definition at line 99 of file memory_pool.h.

## difference_type

template<typename T , typename P = internal::pool_base>

typedef ptrdiff_t tbb::interface6::memory_pool_allocator< T, P >::difference_type

Definition at line 101 of file memory_pool.h.

## pointer

template<typename T , typename P = internal::pool_base>

typedef value_type* tbb::interface6::memory_pool_allocator< T, P >::pointer

Definition at line 96 of file memory_pool.h.

## pool_type

template<typename T , typename P = internal::pool_base>

typedef P tbb::interface6::memory_pool_allocator< T, P >::pool_type

protected

Definition at line 86 of file memory_pool.h.

## reference

template<typename T , typename P = internal::pool_base>

typedef value_type& tbb::interface6::memory_pool_allocator< T, P >::reference

Definition at line 98 of file memory_pool.h.

## size_type

template<typename T , typename P = internal::pool_base>

typedef size_t tbb::interface6::memory_pool_allocator< T, P >::size_type

Definition at line 100 of file memory_pool.h.

## value_type

template<typename T , typename P = internal::pool_base>

typedef tbb::internal::allocator_type<T>::value_type tbb::interface6::memory_pool_allocator< T, P >::value_type

Definition at line 95 of file memory_pool.h.

## Constructor & Destructor Documentation

## memory_pool_allocator() [1/3]

template<typename T , typename P = internal::pool_base>

tbb::interface6::memory_pool_allocator< T, P >::memory_pool_allocator | ( | pool_type & | pool | ) |
throw | ( |
| ) |  |

inline explicit

Definition at line 106 of file memory_pool.h.

: my_pool(&pool) {}
tbb::interface6::memory_pool_allocator::my_pool
pool_type * my_pool
Definition: memory_pool.h:87

## memory_pool_allocator() [2/3]

template<typename T , typename P = internal::pool_base>

tbb::interface6::memory_pool_allocator< T, P >::memory_pool_allocator | ( | const memory_pool_allocator< T, P > & | src | ) |
throw | ( |
| ) |  |

inline

Definition at line 107 of file memory_pool.h.

: my_pool(src.my_pool) {}

## memory_pool_allocator() [3/3]

template<typename T , typename P = internal::pool_base>
template<typename U >

tbb::interface6::memory_pool_allocator< T, P >::memory_pool_allocator | ( | const memory_pool_allocator< U, P > & | src | ) |
throw | ( |
| ) |  |

inline

Definition at line 109 of file memory_pool.h.

: my_pool(src.my_pool) {}

## Member Function Documentation

## address() [1/2]

template<typename T , typename P = internal::pool_base>

const_pointer tbb::interface6::memory_pool_allocator< T, P >::address | ( | const_reference | x | ) | const

inline

Definition at line 112 of file memory_pool.h.

{ return &x; }

## address() [2/2]

template<typename T , typename P = internal::pool_base>

pointer tbb::interface6::memory_pool_allocator< T, P >::address | ( | reference | x | ) | const

inline

Definition at line 111 of file memory_pool.h.

{ return &x; }

## allocate()

template<typename T , typename P = internal::pool_base>

pointer tbb::interface6::memory_pool_allocator< T, P >::allocate | ( | size_type | n,
|  | const void * | = `0`
| ) |  |

inline

Allocate space for n objects.

Definition at line 115 of file memory_pool.h.

{
pointer p = static_cast<pointer>( my_pool->malloc( n*sizeof(value_type) ) );
if (!p)
tbb::internal::throw_exception(std::bad_alloc());
return p;
}
p
void const char const char int ITT_FORMAT __itt_group_sync p
Definition: ittnotify_static.h:91
tbb::internal::throw_exception
void throw_exception(exception_id eid)
Versionless convenience wrapper for throw_exception_v4()
Definition: tbb_exception.h:105
tbb::interface6::memory_pool_allocator::pointer
value_type * pointer
Definition: memory_pool.h:96
tbb::interface6::memory_pool_allocator::value_type
tbb::internal::allocator_type< T >::value_type value_type
Definition: memory_pool.h:95

References tbb::interface6::memory_pool_allocator< T, P >::my_pool, p, and tbb::internal::throw_exception().

Here is the call graph for this function:

## construct() [1/2]

template<typename T , typename P = internal::pool_base>

void tbb::interface6::memory_pool_allocator< T, P >::construct | ( | pointer | p,
|  | const value_type & | value
| ) |  |

inline

Definition at line 139 of file memory_pool.h.

{ ::new((void*)(p)) value_type(value); }
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 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
Definition: ittnotify_static.h:192

References p, and value.

## construct() [2/2]

template<typename T , typename P = internal::pool_base>

void tbb::interface6::memory_pool_allocator< T, P >::construct | ( | pointer | p,
|  | value_type && | value
| ) |  |

inline

Copy-construct value at location pointed to by p.

Definition at line 137 of file memory_pool.h.

{::new((void*)(p)) value_type(std::move(value));}
tbb::move
void move(tbb_thread &t1, tbb_thread &t2)
Definition: tbb_thread.h:319

References tbb::move(), p, and value.

Here is the call graph for this function:

## deallocate()

template<typename T , typename P = internal::pool_base>

void tbb::interface6::memory_pool_allocator< T, P >::deallocate | ( | pointer | p,
|  | size_type |
| ) |  |

inline

Free previously allocated block of memory.

Definition at line 122 of file memory_pool.h.

{
my_pool->free(p);
}

References tbb::interface6::memory_pool_allocator< T, P >::my_pool, and p.

## destroy()

template<typename T , typename P = internal::pool_base>

void tbb::interface6::memory_pool_allocator< T, P >::destroy | ( | pointer | p | ) |

inline

Destroy value at location pointed to by p.

Definition at line 143 of file memory_pool.h.

{ p->~value_type(); }

References p.

## max_size()

template<typename T , typename P = internal::pool_base>

size_type tbb::interface6::memory_pool_allocator< T, P >::max_size | ( |  | ) | const
throw | ( |
| ) |  |

inline

Largest value for which method allocate might succeed.

Definition at line 126 of file memory_pool.h.

{
size_type max = static_cast<size_type>(-1) / sizeof (value_type);
return (max > 0 ? max : 1);
}
tbb::internal::max
T max(const T &val1, const T &val2)
Utility template function returning greater of the two values.
Definition: tbb_misc.h:119
tbb::interface6::memory_pool_allocator::size_type
size_t size_type
Definition: memory_pool.h:100

References tbb::internal::max().

Here is the call graph for this function:

## Friends And Related Function Documentation

## memory_pool_allocator

template<typename T , typename P = internal::pool_base>
template<typename U , typename R >

friend class memory_pool_allocator

friend

Definition at line 89 of file memory_pool.h.

## operator!=

template<typename T , typename P = internal::pool_base>
template<typename V , typename U , typename R >

bool operator!= | ( | const memory_pool_allocator< V, R > & | a,
|  | const memory_pool_allocator< U, R > & | b
| ) |  |

friend

## operator==

template<typename T , typename P = internal::pool_base>
template<typename V , typename U , typename R >

bool operator== | ( | const memory_pool_allocator< V, R > & | a,
|  | const memory_pool_allocator< U, R > & | b
| ) |  |

friend

## Member Data Documentation

## my_pool

template<typename T , typename P = internal::pool_base>

pool_type* tbb::interface6::memory_pool_allocator< T, P >::my_pool

protected

Definition at line 87 of file memory_pool.h.

Referenced by tbb::interface6::memory_pool_allocator< T, P >::allocate(), tbb::interface6::memory_pool_allocator< T, P >::deallocate(), tbb::interface6::operator!=(), and tbb::interface6::operator==().

The documentation for this class was generated from the following file:

- memory_pool.h

Copyright © 2005-2020 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.