31#ifndef ETL_GENERIC_POOL_INCLUDED
32#define ETL_GENERIC_POOL_INCLUDED
37#include "static_assert.h"
40#define ETL_POOL_CPP03_CODE 0
54 template <
size_t VTypeSize,
size_t VAlignment,
size_t VSize>
59 static ETL_CONSTANT
size_t SIZE = VSize;
60 static ETL_CONSTANT
size_t ALIGNMENT = VAlignment;
61 static ETL_CONSTANT
size_t TYPE_SIZE = VTypeSize;
67 :
etl::
ipool(reinterpret_cast<char*>(&buffer[0]), Element_Size, VSize)
80 ETL_STATIC_ASSERT(etl::alignment_of<U>::value <= VAlignment,
"Type has incompatible alignment");
81 ETL_STATIC_ASSERT(
sizeof(U) <= VTypeSize,
"Type too large for pool");
85#if ETL_CPP11_NOT_SUPPORTED || ETL_POOL_CPP03_CODE || ETL_USING_STLPORT
94 ETL_STATIC_ASSERT(etl::alignment_of<U>::value <= VAlignment,
"Type has incompatible alignment");
95 ETL_STATIC_ASSERT(
sizeof(U) <= VTypeSize,
"Type too large for pool");
105 template <
typename U,
typename T1>
108 ETL_STATIC_ASSERT(etl::alignment_of<U>::value <= VAlignment,
"Type has incompatible alignment");
109 ETL_STATIC_ASSERT(
sizeof(U) <= VTypeSize,
"Type too large for pool");
119 template <
typename U,
typename T1,
typename T2>
120 U*
create(
const T1& value1,
const T2& value2)
122 ETL_STATIC_ASSERT(etl::alignment_of<U>::value <= VAlignment,
"Type has incompatible alignment");
123 ETL_STATIC_ASSERT(
sizeof(U) <= VTypeSize,
"Type too large for pool");
133 template <
typename U,
typename T1,
typename T2,
typename T3>
134 U*
create(
const T1& value1,
const T2& value2,
const T3& value3)
136 ETL_STATIC_ASSERT(etl::alignment_of<U>::value <= VAlignment,
"Type has incompatible alignment");
137 ETL_STATIC_ASSERT(
sizeof(U) <= VTypeSize,
"Type too large for pool");
147 template <
typename U,
typename T1,
typename T2,
typename T3,
typename T4>
148 U*
create(
const T1& value1,
const T2& value2,
const T3& value3,
const T4& value4)
150 ETL_STATIC_ASSERT(etl::alignment_of<U>::value <= VAlignment,
"Type has incompatible alignment");
151 ETL_STATIC_ASSERT(
sizeof(U) <= VTypeSize,
"Type too large for pool");
158 template <
typename U,
typename... Args>
161 ETL_STATIC_ASSERT(etl::alignment_of<U>::value <= VAlignment,
"Type has incompatible alignment");
162 ETL_STATIC_ASSERT(
sizeof(U) <= VTypeSize,
"Type too large for pool");
172 template <
typename U>
175 ETL_STATIC_ASSERT(etl::alignment_of<U>::value <= VAlignment,
"Type has incompatible alignment");
176 ETL_STATIC_ASSERT(
sizeof(U) <= VTypeSize,
"Type too large for pool");
186 char value[VTypeSize];
187 typename etl::type_with_alignment<VAlignment>::type dummy;
193 static ETL_CONSTANT uint32_t Element_Size =
sizeof(Element);
200 template <
size_t VTypeSize,
size_t VAlignment,
size_t VSize>
201 ETL_CONSTANT
size_t generic_pool<VTypeSize, VAlignment, VSize>::SIZE;
203 template <
size_t VTypeSize,
size_t VAlignment,
size_t VSize>
204 ETL_CONSTANT
size_t generic_pool<VTypeSize, VAlignment, VSize>::ALIGNMENT;
206 template <
size_t VTypeSize,
size_t VAlignment,
size_t VSize>
207 ETL_CONSTANT
size_t generic_pool<VTypeSize, VAlignment, VSize>::TYPE_SIZE;
214 template <
size_t VTypeSize,
size_t VAlignment>
220 union element_internal
223 char value[VTypeSize];
224 typename etl::type_with_alignment<VAlignment>::type dummy;
227 static const size_t ELEMENT_INTERNAL_SIZE =
sizeof(element_internal);
231 static ETL_CONSTANT
size_t ALIGNMENT = VAlignment;
232 static ETL_CONSTANT
size_t TYPE_SIZE = VTypeSize;
240 :
etl::
ipool(reinterpret_cast<char*>(&buffer[0]), ELEMENT_INTERNAL_SIZE,
size)
250 template <
typename U>
253 ETL_STATIC_ASSERT(etl::alignment_of<U>::value <= VAlignment,
"Type has incompatible alignment");
254 ETL_STATIC_ASSERT(
sizeof(U) <= VTypeSize,
"Type too large for pool");
258#if ETL_CPP11_NOT_SUPPORTED || ETL_POOL_CPP03_CODE || ETL_USING_STLPORT
264 template <
typename U>
267 ETL_STATIC_ASSERT(etl::alignment_of<U>::value <= VAlignment,
"Type has incompatible alignment");
268 ETL_STATIC_ASSERT(
sizeof(U) <= VTypeSize,
"Type too large for pool");
278 template <
typename U,
typename T1>
281 ETL_STATIC_ASSERT(etl::alignment_of<U>::value <= VAlignment,
"Type has incompatible alignment");
282 ETL_STATIC_ASSERT(
sizeof(U) <= VTypeSize,
"Type too large for pool");
292 template <
typename U,
typename T1,
typename T2>
293 U*
create(
const T1& value1,
const T2& value2)
295 ETL_STATIC_ASSERT(etl::alignment_of<U>::value <= VAlignment,
"Type has incompatible alignment");
296 ETL_STATIC_ASSERT(
sizeof(U) <= VTypeSize,
"Type too large for pool");
306 template <
typename U,
typename T1,
typename T2,
typename T3>
307 U*
create(
const T1& value1,
const T2& value2,
const T3& value3)
309 ETL_STATIC_ASSERT(etl::alignment_of<U>::value <= VAlignment,
"Type has incompatible alignment");
310 ETL_STATIC_ASSERT(
sizeof(U) <= VTypeSize,
"Type too large for pool");
320 template <
typename U,
typename T1,
typename T2,
typename T3,
typename T4>
321 U*
create(
const T1& value1,
const T2& value2,
const T3& value3,
const T4& value4)
323 ETL_STATIC_ASSERT(etl::alignment_of<U>::value <= VAlignment,
"Type has incompatible alignment");
324 ETL_STATIC_ASSERT(
sizeof(U) <= VTypeSize,
"Type too large for pool");
331 template <
typename U,
typename... Args>
334 ETL_STATIC_ASSERT(etl::alignment_of<U>::value <= VAlignment,
"Type has incompatible alignment");
335 ETL_STATIC_ASSERT(
sizeof(U) <= VTypeSize,
"Type too large for pool");
345 template <
typename U>
348 ETL_STATIC_ASSERT(etl::alignment_of<U>::value <= VAlignment,
"Type has incompatible alignment");
349 ETL_STATIC_ASSERT(
sizeof(U) <= VTypeSize,
"Type too large for pool");
360 template <
size_t VTypeSize,
size_t VAlignment>
361 ETL_CONSTANT
size_t generic_pool_ext<VTypeSize, VAlignment>::ALIGNMENT;
363 template <
size_t VTypeSize,
size_t VAlignment>
364 ETL_CONSTANT
size_t generic_pool_ext<VTypeSize, VAlignment>::TYPE_SIZE;
Definition alignment.h:251
size_t size() const
Returns the number of allocated items in the pool.
Definition ipool.h:522
U * create(const T1 &value1)
Definition generic_pool.h:106
U * create(const T1 &value1, const T2 &value2, const T3 &value3, const T4 &value4)
Definition generic_pool.h:148
U * create(const T1 &value1)
Definition generic_pool.h:279
U * create(const T1 &value1, const T2 &value2, const T3 &value3)
Definition generic_pool.h:307
generic_pool_ext(element *buffer, size_t size)
Constructor.
Definition generic_pool.h:239
U * create(const T1 &value1, const T2 &value2, const T3 &value3)
Definition generic_pool.h:134
U * create(const T1 &value1, const T2 &value2)
Definition generic_pool.h:120
T * allocate()
Definition ipool.h:333
U * create(const T1 &value1, const T2 &value2, const T3 &value3, const T4 &value4)
Definition generic_pool.h:321
U * create()
Definition generic_pool.h:265
ipool(char *p_buffer_, uint32_t item_size_, uint32_t max_size_)
Constructor.
Definition ipool.h:550
U * allocate()
Definition generic_pool.h:78
generic_pool()
Constructor.
Definition generic_pool.h:66
U * create(const T1 &value1, const T2 &value2)
Definition generic_pool.h:293
void destroy(const U *const p_object)
Definition generic_pool.h:173
U * create()
Definition generic_pool.h:92
U * allocate()
Definition generic_pool.h:251
T * create()
Definition ipool.h:350
void destroy(const T *const p_object)
Definition ipool.h:443
void destroy(const U *const p_object)
Definition generic_pool.h:346
Definition generic_pool.h:216
bitset_ext
Definition absolute.h:40