18 #ifndef EASTL_INTERNAL_FIXED_POOL_H
19 #define EASTL_INTERNAL_FIXED_POOL_H
22 #include <EABase/eabase.h>
23 #if defined(EA_PRAGMA_ONCE_SUPPORTED)
27 #include <EASTL/internal/config.h>
28 #include <EASTL/functional.h>
29 #include <EASTL/memory.h>
30 #include <EASTL/allocator.h>
31 #include <EASTL/type_traits.h>
34 EA_DISABLE_ALL_VC_WARNINGS();
36 EA_RESTORE_ALL_VC_WARNINGS();
39 EA_DISABLE_VC_WARNING(4275);
49 #ifndef EASTL_FIXED_POOL_DEFAULT_NAME
50 #define EASTL_FIXED_POOL_DEFAULT_NAME EASTL_DEFAULT_NAME_PREFIX " fixed_pool"
81 template <
size_t size,
size_t alignment>
102 template<
size_t size>
105 template<
size_t size>
108 template<
size_t size>
111 template<
size_t size>
114 template<
size_t size>
117 template<
size_t size>
139 : mpHead((
Link*)pMemory)
140 , mpNext((
Link*)pMemory)
141 , mpCapacity((
Link*)pMemory)
144 #if EASTL_FIXED_SIZE_TRACKING_ENABLED
177 EASTL_API
void init(
void* pMemory,
size_t memorySize,
size_t nodeSize,
178 size_t alignment,
size_t alignmentOffset = 0);
188 #if EASTL_FIXED_SIZE_TRACKING_ENABLED
202 return (mpHead != NULL) || (mpNext != mpCapacity);
218 #if EASTL_FIXED_SIZE_TRACKING_ENABLED
219 uint32_t mnCurrentSize;
261 fixed_pool(
void* pMemory,
size_t memorySize,
size_t nodeSize,
262 size_t alignment,
size_t alignmentOffset = 0)
264 init(pMemory, memorySize, nodeSize, alignment, alignmentOffset);
294 Link* pLink = mpHead;
298 #if EASTL_FIXED_SIZE_TRACKING_ENABLED
299 if(++mnCurrentSize > mnPeakSize)
300 mnPeakSize = mnCurrentSize;
303 mpHead = pLink->mpNext;
311 if(mpNext != mpCapacity)
315 mpNext =
reinterpret_cast<Link*
>(
reinterpret_cast<char*
>(mpNext) + mnNodeSize);
317 #if EASTL_FIXED_SIZE_TRACKING_ENABLED
318 if(++mnCurrentSize > mnPeakSize)
319 mnPeakSize = mnCurrentSize;
329 void* allocate(
size_t ,
size_t )
342 #if EASTL_FIXED_SIZE_TRACKING_ENABLED
346 ((
Link*)p)->mpNext = mpHead;
354 const char* get_name()
const
356 return EASTL_FIXED_POOL_DEFAULT_NAME;
360 void set_name(
const char*)
377 template <
typename OverflowAllocator = EASTLAllocatorType>
381 typedef OverflowAllocator overflow_allocator_type;
386 mOverflowAllocator(EASTL_FIXED_POOL_DEFAULT_NAME)
401 size_t alignment,
size_t alignmentOffset = 0)
402 : mOverflowAllocator(EASTL_FIXED_POOL_DEFAULT_NAME)
406 mpPoolBegin = pMemory;
411 size_t alignment,
size_t alignmentOffset,
412 const overflow_allocator_type&
allocator)
417 mpPoolBegin = pMemory;
432 #if EASTL_ALLOCATOR_COPY_ENABLED
433 mOverflowAllocator = x.mOverflowAllocator;
442 void init(
void* pMemory,
size_t memorySize,
size_t nodeSize,
443 size_t alignment,
size_t alignmentOffset = 0)
447 mpPoolBegin = pMemory;
454 Link* pLink = mpHead;
460 mpHead = pLink->mpNext;
467 if(mpNext != mpCapacity)
470 mpNext =
reinterpret_cast<Link*
>(
reinterpret_cast<char*
>(mpNext) + mnNodeSize);
473 p = mOverflowAllocator.allocate(mnNodeSize);
476 #if EASTL_FIXED_SIZE_TRACKING_ENABLED
477 if(p && (++mnCurrentSize > mnPeakSize))
478 mnPeakSize = mnCurrentSize;
485 void* allocate(
size_t alignment,
size_t alignmentOffset)
488 Link* pLink = mpHead;
494 mpHead = pLink->mpNext;
501 if (mpNext != mpCapacity)
504 mpNext =
reinterpret_cast<Link*
>(
reinterpret_cast<char*
>(mpNext)+mnNodeSize);
508 p =
allocate_memory(mOverflowAllocator, mnNodeSize, alignment, alignmentOffset);
509 EASTL_ASSERT_MSG(p !=
nullptr,
"the behaviour of eastl::allocators that return nullptr is not defined.");
514 #if EASTL_FIXED_SIZE_TRACKING_ENABLED
515 if (p && (++mnCurrentSize > mnPeakSize))
516 mnPeakSize = mnCurrentSize;
522 void deallocate(
void* p)
524 #if EASTL_FIXED_SIZE_TRACKING_ENABLED
528 if((p >= mpPoolBegin) && (p < mpCapacity))
530 ((
Link*)p)->mpNext = mpHead;
534 mOverflowAllocator.deallocate(p, (
size_t)mnNodeSize);
541 const char* get_name()
const
543 return mOverflowAllocator.get_name();
547 void set_name(
const char* pName)
549 mOverflowAllocator.set_name(pName);
553 const overflow_allocator_type& get_overflow_allocator()
const
555 return mOverflowAllocator;
559 overflow_allocator_type& get_overflow_allocator()
561 return mOverflowAllocator;
565 void set_overflow_allocator(
const overflow_allocator_type& overflowAllocator)
567 mOverflowAllocator = overflowAllocator;
570 OverflowAllocator mOverflowAllocator;
605 template <
size_t nodeSize,
size_t nodeCount,
size_t nodeAlignment,
size_t nodeAlignmentOffset,
bool bEnableOverflow,
typename OverflowAllocator = EASTLAllocatorType>
611 typedef OverflowAllocator overflow_allocator_type;
615 kNodeSize = nodeSize,
616 kNodeCount = nodeCount,
617 kNodesSize = nodeCount * nodeSize,
618 kBufferSize = kNodesSize + ((nodeAlignment > 1) ? nodeSize-1 : 0) + nodeAlignmentOffset,
619 kNodeAlignment = nodeAlignment,
620 kNodeAlignmentOffset = nodeAlignmentOffset
634 : mPool(pNodeBuffer, kNodesSize, kNodeSize, kNodeAlignment, kNodeAlignmentOffset)
640 : mPool(pNodeBuffer, kNodesSize, kNodeSize, kNodeAlignment, kNodeAlignmentOffset,
allocator)
660 : mPool(x.mPool.mpNext, kNodesSize, kNodeSize, kNodeAlignment, kNodeAlignmentOffset, x.mPool.mOverflowAllocator)
665 this_type& operator=(
const this_type& x)
672 void* allocate(
size_t n,
int = 0)
675 EASTL_ASSERT(n == kNodeSize);
676 return mPool.allocate();
680 void* allocate(
size_t n,
size_t alignment,
size_t offset,
int = 0)
683 EASTL_ASSERT(n == kNodeSize);
684 return mPool.allocate(alignment, offset);
688 void deallocate(
void* p,
size_t)
700 return mPool.can_allocate();
711 mPool.init(pNodeBuffer, kBufferSize, kNodeSize, kNodeAlignment, kNodeAlignmentOffset);
715 const char* get_name()
const
717 return mPool.get_name();
721 void set_name(
const char* pName)
723 mPool.set_name(pName);
727 const overflow_allocator_type& get_overflow_allocator() const EA_NOEXCEPT
729 return mPool.mOverflowAllocator;
733 overflow_allocator_type& get_overflow_allocator() EA_NOEXCEPT
735 return mPool.mOverflowAllocator;
739 void set_overflow_allocator(
const overflow_allocator_type& allocator)
741 mPool.mOverflowAllocator = allocator;
745 void copy_overflow_allocator(
const this_type& x)
747 mPool.mOverflowAllocator = x.mPool.mOverflowAllocator;
756 template <
size_t nodeSize,
size_t nodeCount,
size_t nodeAlignment,
size_t nodeAlignmentOffset,
typename OverflowAllocator>
762 typedef OverflowAllocator overflow_allocator_type;
766 kNodeSize = nodeSize,
767 kNodeCount = nodeCount,
768 kNodesSize = nodeCount * nodeSize,
769 kBufferSize = kNodesSize + ((nodeAlignment > 1) ? nodeSize-1 : 0) + nodeAlignmentOffset,
770 kNodeAlignment = nodeAlignment,
771 kNodeAlignmentOffset = nodeAlignmentOffset
779 : mPool(pNodeBuffer, kNodesSize, kNodeSize, kNodeAlignment, kNodeAlignmentOffset)
785 : mPool(pNodeBuffer, kNodesSize, kNodeSize, kNodeAlignment, kNodeAlignmentOffset)
805 : mPool(x.mPool.mpNext, kNodesSize, kNodeSize, kNodeAlignment, kNodeAlignmentOffset)
810 this_type& operator=(
const this_type& x)
817 void* allocate(
size_t n,
int = 0)
820 EASTL_ASSERT(n == kNodeSize);
825 void* allocate(
size_t n,
size_t alignment,
size_t offset,
int = 0)
828 EASTL_ASSERT(n == kNodeSize);
829 return mPool.
allocate(alignment, offset);
833 void deallocate(
void* p,
size_t)
845 void reset(
void* pNodeBuffer)
847 mPool.
init(pNodeBuffer, kBufferSize, kNodeSize, kNodeAlignment, kNodeAlignmentOffset);
851 const char* get_name()
const
853 return mPool.get_name();
857 void set_name(
const char* pName)
859 mPool.set_name(pName);
863 const overflow_allocator_type& get_overflow_allocator() const EA_NOEXCEPT
866 overflow_allocator_type* pNULL = NULL;
871 overflow_allocator_type& get_overflow_allocator() EA_NOEXCEPT
874 overflow_allocator_type* pNULL = NULL;
879 void set_overflow_allocator(
const overflow_allocator_type& )
886 void copy_overflow_allocator(
const this_type&)
900 template <
size_t nodeSize,
size_t nodeCount,
size_t nodeAlignment,
size_t nodeAlignmentOffset,
bool bEnableOverflow,
typename OverflowAllocator>
901 inline bool operator==(
const fixed_node_allocator<nodeSize, nodeCount, nodeAlignment, nodeAlignmentOffset, bEnableOverflow, OverflowAllocator>& a,
902 const fixed_node_allocator<nodeSize, nodeCount, nodeAlignment, nodeAlignmentOffset, bEnableOverflow, OverflowAllocator>& b)
908 template <
size_t nodeSize,
size_t nodeCount,
size_t nodeAlignment,
size_t nodeAlignmentOffset,
bool bEnableOverflow,
typename OverflowAllocator>
909 inline bool operator!=(
const fixed_node_allocator<nodeSize, nodeCount, nodeAlignment, nodeAlignmentOffset, bEnableOverflow, OverflowAllocator>& a,
910 const fixed_node_allocator<nodeSize, nodeCount, nodeAlignment, nodeAlignmentOffset, bEnableOverflow, OverflowAllocator>& b)
937 template <
size_t bucketCount,
size_t nodeSize,
size_t nodeCount,
size_t nodeAlignment,
size_t nodeAlignmentOffset,
bool bEnableOverflow,
typename OverflowAllocator = EASTLAllocatorType>
943 typedef OverflowAllocator overflow_allocator_type;
947 kBucketCount = bucketCount + 1,
948 kBucketsSize = bucketCount *
sizeof(
void*),
949 kNodeSize = nodeSize,
950 kNodeCount = nodeCount,
951 kNodesSize = nodeCount * nodeSize,
952 kBufferSize = kNodesSize + ((nodeAlignment > 1) ? nodeSize-1 : 0) + nodeAlignmentOffset,
953 kNodeAlignment = nodeAlignment,
954 kNodeAlignmentOffset = nodeAlignmentOffset,
955 kAllocFlagBuckets = 0x00400000
960 void* mpBucketBuffer;
970 : mPool(pNodeBuffer, kBufferSize, kNodeSize, kNodeAlignment, kNodeAlignmentOffset),
978 : mPool(pNodeBuffer, kBufferSize, kNodeSize, kNodeAlignment, kNodeAlignmentOffset,
allocator),
986 : mPool(pNodeBuffer, kBufferSize, kNodeSize, kNodeAlignment, kNodeAlignmentOffset),
987 mpBucketBuffer(pBucketBuffer)
993 : mPool(pNodeBuffer, kBufferSize, kNodeSize, kNodeAlignment, kNodeAlignmentOffset,
allocator),
994 mpBucketBuffer(pBucketBuffer)
1005 : mPool(x.mPool.mpHead, kBufferSize, kNodeSize, kNodeAlignment, kNodeAlignmentOffset, x.mPool.mOverflowAllocator),
1006 mpBucketBuffer(x.mpBucketBuffer)
1018 void* allocate(
size_t n,
int flags = 0)
1021 EASTL_CT_ASSERT(kAllocFlagBuckets == 0x00400000);
1023 if((flags & kAllocFlagBuckets) == 0)
1025 EASTL_ASSERT(n == kNodeSize); EA_UNUSED(n);
1026 return mPool.allocate();
1030 if ((flags & kAllocFlagBuckets) == kAllocFlagBuckets && (n > kBucketsSize))
1031 return get_overflow_allocator().allocate(n);
1033 EASTL_ASSERT(n <= kBucketsSize);
1034 return mpBucketBuffer;
1038 void* allocate(
size_t n,
size_t alignment,
size_t offset,
int flags = 0)
1041 if ((flags & kAllocFlagBuckets) == 0)
1043 EASTL_ASSERT(n == kNodeSize); EA_UNUSED(n);
1044 return mPool.allocate(alignment, offset);
1048 if ((flags & kAllocFlagBuckets) == kAllocFlagBuckets && (n > kBucketsSize))
1049 return get_overflow_allocator().allocate(n, alignment, offset);
1051 EASTL_ASSERT(n <= kBucketsSize);
1052 return mpBucketBuffer;
1056 void deallocate(
void* p,
size_t)
1058 if(p != mpBucketBuffer)
1059 mPool.deallocate(p);
1063 bool can_allocate()
const
1065 return mPool.can_allocate();
1069 void reset(
void* pNodeBuffer)
1072 mPool.init(pNodeBuffer, kBufferSize, kNodeSize, kNodeAlignment, kNodeAlignmentOffset);
1076 const char* get_name()
const
1078 return mPool.get_name();
1082 void set_name(
const char* pName)
1084 mPool.set_name(pName);
1088 const overflow_allocator_type& get_overflow_allocator()
const
1090 return mPool.mOverflowAllocator;
1094 overflow_allocator_type& get_overflow_allocator()
1096 return mPool.mOverflowAllocator;
1100 void set_overflow_allocator(
const overflow_allocator_type& allocator)
1102 mPool.mOverflowAllocator = allocator;
1106 void copy_overflow_allocator(
const this_type& x)
1108 mPool.mOverflowAllocator = x.mPool.mOverflowAllocator;
1117 template <
size_t bucketCount,
size_t nodeSize,
size_t nodeCount,
size_t nodeAlignment,
size_t nodeAlignmentOffset,
typename OverflowAllocator>
1123 typedef OverflowAllocator overflow_allocator_type;
1127 kBucketCount = bucketCount + 1,
1128 kBucketsSize = bucketCount *
sizeof(
void*),
1129 kNodeSize = nodeSize,
1130 kNodeCount = nodeCount,
1131 kNodesSize = nodeCount * nodeSize,
1132 kBufferSize = kNodesSize + ((nodeAlignment > 1) ? nodeSize-1 : 0) + nodeAlignmentOffset,
1133 kNodeAlignment = nodeAlignment,
1134 kNodeAlignmentOffset = nodeAlignmentOffset,
1135 kAllocFlagBuckets = 0x00400000
1140 void* mpBucketBuffer;
1150 : mPool(pNodeBuffer, kBufferSize, kNodeSize, kNodeAlignment, kNodeAlignmentOffset),
1151 mpBucketBuffer(NULL)
1157 : mPool(pNodeBuffer, kBufferSize, kNodeSize, kNodeAlignment, kNodeAlignmentOffset),
1158 mpBucketBuffer(NULL)
1165 : mPool(pNodeBuffer, kBufferSize, kNodeSize, kNodeAlignment, kNodeAlignmentOffset),
1166 mpBucketBuffer(pBucketBuffer)
1172 : mPool(pNodeBuffer, kBufferSize, kNodeSize, kNodeAlignment, kNodeAlignmentOffset),
1173 mpBucketBuffer(pBucketBuffer)
1184 : mPool(x.mPool.mpHead, kBufferSize, kNodeSize, kNodeAlignment, kNodeAlignmentOffset),
1185 mpBucketBuffer(x.mpBucketBuffer)
1197 void* allocate(
size_t n,
int flags = 0)
1200 EASTL_CT_ASSERT(kAllocFlagBuckets == 0x00400000);
1201 if((flags & kAllocFlagBuckets) == 0)
1203 EASTL_ASSERT(n == kNodeSize); (void)n;
1208 EASTL_ASSERT(n <= kBucketsSize);
1209 return mpBucketBuffer;
1213 void* allocate(
size_t n,
size_t alignment,
size_t offset,
int flags = 0)
1216 if((flags & kAllocFlagBuckets) == 0)
1218 EASTL_ASSERT(n == kNodeSize); (void)n;
1219 return mPool.
allocate(alignment, offset);
1223 EASTL_ASSERT(n <= kBucketsSize);
1224 return mpBucketBuffer;
1228 void deallocate(
void* p,
size_t)
1230 if(p != mpBucketBuffer)
1235 bool can_allocate()
const
1241 void reset(
void* pNodeBuffer)
1244 mPool.
init(pNodeBuffer, kBufferSize, kNodeSize, kNodeAlignment, kNodeAlignmentOffset);
1248 const char* get_name()
const
1250 return mPool.get_name();
1254 void set_name(
const char* pName)
1256 mPool.set_name(pName);
1260 const overflow_allocator_type& get_overflow_allocator() const EA_NOEXCEPT
1262 EASTL_ASSERT(
false);
1263 overflow_allocator_type* pNULL = NULL;
1268 overflow_allocator_type& get_overflow_allocator() EA_NOEXCEPT
1270 EASTL_ASSERT(
false);
1271 overflow_allocator_type* pNULL = NULL;
1275 void set_overflow_allocator(
const overflow_allocator_type& )
1278 EASTL_ASSERT(
false);
1281 void copy_overflow_allocator(
const this_type&)
1293 template <
size_t bucketCount,
size_t nodeSize,
size_t nodeCount,
size_t nodeAlignment,
size_t nodeAlignmentOffset,
bool bEnableOverflow,
typename OverflowAllocator>
1294 inline bool operator==(
const fixed_hashtable_allocator<bucketCount, nodeSize, nodeCount, nodeAlignment, nodeAlignmentOffset, bEnableOverflow, OverflowAllocator>& a,
1295 const fixed_hashtable_allocator<bucketCount, nodeSize, nodeCount, nodeAlignment, nodeAlignmentOffset, bEnableOverflow, OverflowAllocator>& b)
1301 template <
size_t bucketCount,
size_t nodeSize,
size_t nodeCount,
size_t nodeAlignment,
size_t nodeAlignmentOffset,
bool bEnableOverflow,
typename OverflowAllocator>
1302 inline bool operator!=(
const fixed_hashtable_allocator<bucketCount, nodeSize, nodeCount, nodeAlignment, nodeAlignmentOffset, bEnableOverflow, OverflowAllocator>& a,
1303 const fixed_hashtable_allocator<bucketCount, nodeSize, nodeCount, nodeAlignment, nodeAlignmentOffset, bEnableOverflow, OverflowAllocator>& b)
1327 template <
size_t nodeSize,
size_t nodeCount,
size_t nodeAlignment,
size_t nodeAlignmentOffset,
bool bEnableOverflow,
typename OverflowAllocator = EASTLAllocatorType>
1332 typedef OverflowAllocator overflow_allocator_type;
1336 kNodeSize = nodeSize,
1337 kNodeCount = nodeCount,
1338 kNodesSize = nodeCount * nodeSize,
1339 kBufferSize = kNodesSize + ((nodeAlignment > 1) ? nodeSize-1 : 0) + nodeAlignmentOffset,
1340 kNodeAlignment = nodeAlignment,
1341 kNodeAlignmentOffset = nodeAlignmentOffset
1345 overflow_allocator_type mOverflowAllocator;
1356 : mpPoolBegin(pNodeBuffer)
1361 : mOverflowAllocator(
allocator), mpPoolBegin(pNodeBuffer)
1367 mpPoolBegin = x.mpPoolBegin;
1368 mOverflowAllocator = x.mOverflowAllocator;
1375 #if EASTL_ALLOCATOR_COPY_ENABLED
1376 mOverflowAllocator = x.mOverflowAllocator;
1384 void* allocate(
size_t n,
int flags = 0)
1386 return mOverflowAllocator.allocate(n, flags);
1389 void* allocate(
size_t n,
size_t alignment,
size_t offset,
int flags = 0)
1391 return mOverflowAllocator.allocate(n, alignment, offset, flags);
1394 void deallocate(
void* p,
size_t n)
1396 if(p != mpPoolBegin)
1397 mOverflowAllocator.deallocate(p, n);
1400 const char* get_name()
const
1402 return mOverflowAllocator.get_name();
1405 void set_name(
const char* pName)
1407 mOverflowAllocator.set_name(pName);
1410 const overflow_allocator_type& get_overflow_allocator()
const EA_NOEXCEPT
1412 return mOverflowAllocator;
1415 overflow_allocator_type& get_overflow_allocator() EA_NOEXCEPT
1417 return mOverflowAllocator;
1420 void set_overflow_allocator(
const overflow_allocator_type&
allocator)
1425 void copy_overflow_allocator(
const this_type& x)
1427 mOverflowAllocator = x.mOverflowAllocator;
1433 template <
size_t nodeSize,
size_t nodeCount,
size_t nodeAlignment,
size_t nodeAlignmentOffset,
typename OverflowAllocator>
1438 typedef OverflowAllocator overflow_allocator_type;
1442 kNodeSize = nodeSize,
1443 kNodeCount = nodeCount,
1444 kNodesSize = nodeCount * nodeSize,
1445 kBufferSize = kNodesSize + ((nodeAlignment > 1) ? nodeSize-1 : 0) + nodeAlignmentOffset,
1446 kNodeAlignment = nodeAlignment,
1447 kNodeAlignmentOffset = nodeAlignmentOffset
1482 EASTL_ASSERT(
false);
1486 void* allocate(
size_t ,
size_t ,
size_t ,
int = 0)
1488 EASTL_ASSERT(
false);
1492 void deallocate(
void* ,
size_t )
1496 const char* get_name()
const
1498 return EASTL_FIXED_POOL_DEFAULT_NAME;
1501 void set_name(
const char* )
1505 const overflow_allocator_type& get_overflow_allocator() const EA_NOEXCEPT
1507 EASTL_ASSERT(
false);
1508 overflow_allocator_type* pNULL = NULL;
1512 overflow_allocator_type& get_overflow_allocator() EA_NOEXCEPT
1514 EASTL_ASSERT(
false);
1515 overflow_allocator_type* pNULL = NULL;
1519 void set_overflow_allocator(
const overflow_allocator_type& )
1522 EASTL_ASSERT(
false);
1525 void copy_overflow_allocator(
const this_type&)
1537 template <
size_t nodeSize,
size_t nodeCount,
size_t nodeAlignment,
size_t nodeAlignmentOffset,
bool bEnableOverflow,
typename OverflowAllocator>
1538 inline bool operator==(
const fixed_vector_allocator<nodeSize, nodeCount, nodeAlignment, nodeAlignmentOffset, bEnableOverflow, OverflowAllocator>& a,
1539 const fixed_vector_allocator<nodeSize, nodeCount, nodeAlignment, nodeAlignmentOffset, bEnableOverflow, OverflowAllocator>& b)
1545 template <
size_t nodeSize,
size_t nodeCount,
size_t nodeAlignment,
size_t nodeAlignmentOffset,
bool bEnableOverflow,
typename OverflowAllocator>
1546 inline bool operator!=(
const fixed_vector_allocator<nodeSize, nodeCount, nodeAlignment, nodeAlignmentOffset, bEnableOverflow, OverflowAllocator>& a,
1547 const fixed_vector_allocator<nodeSize, nodeCount, nodeAlignment, nodeAlignmentOffset, bEnableOverflow, OverflowAllocator>& b)
1573 template <
typename Container,
bool UseHeapTemporary>
1577 static void swap(Container& a, Container& b);
1581 template <
typename Container>
1585 static void swap(Container& a, Container& b)
1587 Container temp(EASTL_MOVE(a));
1589 b = EASTL_MOVE(temp);
1594 template <
typename Container>
1598 static void swap(Container& a, Container& b)
1600 EASTLAllocatorType
allocator(*EASTLAllocatorDefault(), EASTL_TEMP_DEFAULT_NAME);
1601 void*
const pMemory =
allocator.allocate(
sizeof(a));
1605 Container* pTemp = ::new(pMemory) Container(EASTL_MOVE(a));
1607 b = EASTL_MOVE(*pTemp);
1609 pTemp->~Container();
1610 allocator.deallocate(pMemory,
sizeof(a));
1616 template<
typename Container>
1617 void fixed_swap(Container& a, Container& b)
1619 return fixed_swap_impl<Container,
sizeof(Container) >= EASTL_MAX_STACK_USAGE>::swap(a, b);
1627 EA_RESTORE_VC_WARNING();
Definition: allocator.h:52
Definition: fixed_pool.h:1119
fixed_hashtable_allocator(const this_type &x)
Definition: fixed_pool.h:1183
Definition: fixed_pool.h:939
fixed_hashtable_allocator(const this_type &x)
Definition: fixed_pool.h:1004
Definition: fixed_pool.h:758
fixed_node_allocator(const this_type &x)
Definition: fixed_pool.h:804
Definition: fixed_pool.h:607
void reset(void *pNodeBuffer)
Definition: fixed_pool.h:709
fixed_node_allocator(const this_type &x)
Definition: fixed_pool.h:659
bool can_allocate() const
Definition: fixed_pool.h:698
Definition: fixed_pool.h:379
Definition: fixed_pool.h:241
void * allocate()
Definition: fixed_pool.h:292
fixed_pool(void *pMemory, size_t memorySize, size_t nodeSize, size_t alignment, size_t alignmentOffset=0)
Definition: fixed_pool.h:261
void deallocate(void *p)
Definition: fixed_pool.h:340
bool can_allocate() const
Definition: fixed_pool.h:200
fixed_pool & operator=(const fixed_pool &)
Definition: fixed_pool.h:280
fixed_pool(void *pMemory=NULL)
Definition: fixed_pool.h:251
Definition: fixed_pool.h:1575
Definition: fixed_pool.h:1435
void * allocate(size_t, int=0)
Definition: fixed_pool.h:1480
Definition: fixed_pool.h:1329
EA Standard Template Library.
Definition: algorithm.h:288
char EASTL_MAY_ALIAS aligned_buffer_char
Definition: fixed_pool.h:79
void * allocate_memory(Allocator &a, size_t n, size_t alignment, size_t alignmentOffset)
Definition: allocator.h:354
Definition: fixed_pool.h:82
Definition: fixed_pool.h:209
Definition: fixed_pool.h:134
fixed_pool_base(void *pMemory=NULL)
Definition: fixed_pool.h:138
fixed_pool_base & operator=(const fixed_pool_base &)
Definition: fixed_pool.h:163
bool can_allocate() const
Definition: fixed_pool.h:200
EASTL_API void init(void *pMemory, size_t memorySize, size_t nodeSize, size_t alignment, size_t alignmentOffset=0)
Definition: fixed_pool.cpp:15
size_t peak_size() const
Definition: fixed_pool.h:186
Definition: red_black_tree.h:152
Definition: type_traits.h:348