1 #ifndef mempool___mempool_h
2 #define mempool___mempool_h
11 #define MEMPOOL_OVERFLOW 3.0f / 4.0f //Changes how full a pool is before going to fallbacks
13 #define MEMPOOL_DETERMINE_SCALAR 5.0f / 3.0f //Gives you this times the max number at any given time from distribution
14 #define MEMPOOL_FALLBACK_DEPTH 3
20 #define __MEMPOOL_MAJOR__ 1
21 #define __MEMPOOL_MINOR__ 2
22 #define __MEMPOOL_PATCH__ 0
23 #define __MEMPOOL_VERSION__ (__MEMPOOL_MAJOR__ * 10000 + __MEMPOOL_MINOR__ * 100 + __MEMPOOL_PATCH__)
29 #ifdef MEMPOOL_DEBUGGING
31 #define MEMPOOL_DEBUG(x) std::cout << x << std::endl;
33 #define MEMPOOL_DEBUG(x)
36 #ifdef MEMPOOL_ASSERTS
38 #define MEMPOOL_ASSERT(condition) if (pool_unlikely(!(condition))){ std::cout << #condition << " isn't true" << std::endl; }
39 #define MEMPOOL_ASSERT2(condition, out) if (pool_unlikely(!(condition))){ std::cout << out << std::endl; }
41 #define MEMPOOL_ASSERT(condition)
42 #define MEMPOOL_ASSERT2(condition, out)
45 #ifdef MEMPOOL_PERFORMANCE_DEBUGGING
49 #define MEMPOOL_PERFORMANCE_DEBUG(x) std::cout << x << std::endl;
51 #define MEMPOOL_PERFORMANCE_DEBUG(x)
61 #define POOL_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
63 #define POOL_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100)
66 #if (POOL_GCC_VERSION >= 40300)
67 #define pool_hot pool_nothrow __attribute__ ((hot))
69 #define pool_hot pool_nothrow
72 #if (POOL_GCC_VERSION >= 29600)
73 #define pool_likely(x) __builtin_expect((long)((bool)(x)),1)
74 #define pool_unlikely(x) __builtin_expect((long)((bool)(x)),0)
76 #define pool_likely(x) x
77 #define pool_unlikely(x) x
80 #define pool_nothrow throw()
82 #define pool_hot pool_nothrow
83 #define pool_likely(x) x
84 #define pool_unlikely(x) x
95 class mempool_callbacks {
97 typedef void * (*mallocer_t)(size_t);
98 typedef void(*freer_t)(
void *);
99 typedef void * (*reallocer_t)(
void *, size_t);
102 static inline void set(mallocer_t mallocer, reallocer_t reallocer, freer_t freer) pool_nothrow {
103 get_instance()._malloc = mallocer;
104 get_instance()._free = freer;
105 get_instance()._realloc = reallocer;
109 static inline void * allocate(
size_t size) pool_nothrow {
110 MEMPOOL_DEBUG(
"Returing malloced memory:" << size <<
" bytes");
111 return get_instance()._malloc(size);
115 static inline void deallocate(
void * ptr) pool_nothrow {
116 MEMPOOL_DEBUG(
"Freeing malloced memory: " << ptr);
117 get_instance()._free(ptr);
120 static inline void * reallocate(
void * ptr,
size_t size) pool_nothrow {
121 MEMPOOL_DEBUG(
"Reallocating memory: " << ptr <<
" to " << size <<
" bytes");
122 return get_instance()._realloc(ptr, size);
126 static inline mempool_callbacks & get_instance(
void) pool_nothrow {
127 static mempool_callbacks _single(std::malloc, std::realloc, std::free);
132 inline mempool_callbacks(mallocer_t mallocer, reallocer_t reallocer, freer_t freer) :
139 mempool_callbacks & operator = (
const mempool_callbacks & other);
140 mempool_callbacks(
const mempool_callbacks & other);
144 reallocer_t _realloc;
149 template <
typename T,
size_t size>
150 class object_memory_pool;
152 template <
size_t bytes,
size_t size>
153 class memory_pool_no_fullflag {
155 memory_pool_no_fullflag<bytes, size>():
159 threshold((
size_t)((
float)size * (MEMPOOL_OVERFLOW))),
160 memoryPool_end(memoryPool_start + (size * bytes)),
161 used_end(used_start + size),
162 runningPointer(used_start)
164 std::memset(used_start, 0, size *
sizeof(
bool));
167 virtual ~memory_pool_no_fullflag(
void){
169 _link -> ~memory_pool_no_fullflag();
170 mempool_callbacks::deallocate(_link);
174 inline size_t load(
void) const pool_nothrow {
178 inline void * allocate(
void) pool_hot {
179 if (
void * res = allocate_nofallback()){
182 return _link_allocate();
185 inline void deallocate(
void * ptr) pool_hot {
186 if (memory_pool_no_fullflag<bytes, size> * container = contains(ptr)){
187 container -> deallocate_nofallback(ptr);
189 mempool_callbacks::deallocate(ptr);
193 void * allocate_nofallback() pool_hot {
194 if (!(*runningPointer))
return _return_current();
195 if (++runningPointer >= used_end) runningPointer = used_start;
196 if (current < threshold){
198 const bool * position = runningPointer;
200 if (!(*runningPointer))
return _return_current();
201 if (++runningPointer >= used_end) runningPointer = used_start;
202 }
while (position != runningPointer);
203 MEMPOOL_ASSERT2(
false,
"Got to impossible code location");
206 MEMPOOL_DEBUG(
"Returing null");
210 void deallocate_nofallback(
void * ptr) pool_hot {
211 MEMPOOL_ASSERT2(current,
"current not positive");
213 MEMPOOL_DEBUG(
"Freeing slot " << ((
char*)ptr - memoryPool_start) / bytes);
214 MEMPOOL_DEBUG(
" pointer=" << ptr);
215 MEMPOOL_ASSERT2((((
char*)ptr - memoryPool_start) / bytes) < size,
"Freeing slot " << (((
char*)ptr - memoryPool_start) / bytes) <<
" in a pool with only " << size <<
" items");
216 MEMPOOL_ASSERT2(used_start[((
char*)ptr - memoryPool_start) / bytes],
"Freeing " << ptr <<
" and it's already been freed");
217 used_start[(((
char*)ptr - memoryPool_start) / bytes)] =
false;
220 inline memory_pool_no_fullflag<bytes, size> * contains(
void * ptr) pool_hot {
221 if ((ptr >= memoryPool_start) && (ptr < memoryPool_end))
return this;
222 return (_link) ? _link -> contains(ptr) : NULL;
225 #ifdef MEMPOOL_PERFORMANCE_DEBUGGING
226 const char *
const getName(
void){
return "memory_pool_no_fullflag"; }
228 const char * getDepth(){
229 static const char * depths[15] = {
246 if (depth > 14)
return depths[14];
247 return depths[depth];
250 std::string dump(
void){
251 std::stringstream output;
252 output << getDepth() << getName() <<
"<" << bytes <<
", " << size <<
">: " << (
void*)
this << std::endl;
253 output << getDepth() <<
"Currently holding: " << current <<
" items." << std::endl;
255 output << getDepth() <<
"+";
256 for(
int i = 0; i < 78; ++i){
259 output <<
"+" << std::endl << getDepth() <<
"|";
263 for(i = 0; i < size; ++i){
264 if ((i % 80 == 0) && (i != 0)){
265 output <<
"|" << std::endl << getDepth() <<
"|";
267 if (i == (runningPointer - used_start)){
273 }
else if (used_start[i]){
280 for(; (i % 80) != 0; ++i){
285 output << getDepth() <<
"+";
286 for(i = 0; i < 78; ++i){
291 output <<
"----+" << std::endl;
298 memory_pool_no_fullflag & operator = (
const memory_pool_no_fullflag & other);
299 memory_pool_no_fullflag(
const memory_pool_no_fullflag & other);
301 inline void * _return_current(
void) pool_hot {
302 *runningPointer =
true;
304 MEMPOOL_DEBUG(
"Returning slot " << runningPointer - used_start <<
" at depth " << depth);
305 MEMPOOL_DEBUG(
" memoryPool_start=" << (
void*)memoryPool_start);
306 MEMPOOL_DEBUG(
" memoryPool_end =" << (
void*)memoryPool_end);
307 MEMPOOL_DEBUG(
" return value =" << (
void*)(memoryPool_start + ((runningPointer - used_start) * bytes)));
308 MEMPOOL_ASSERT2(((memoryPool_start + ((runningPointer - used_start) * bytes))) < memoryPool_end,
"Returning pointer outside the high end of the pool");
309 MEMPOOL_ASSERT2(((memoryPool_start + ((runningPointer - used_start) * bytes))) >= memoryPool_start,
"Returning pointer outside the low end of the pool");
310 const bool *
const pre = runningPointer;
311 if (++runningPointer >= used_end) runningPointer = used_start;
312 return memoryPool_start + ((pre - used_start) * bytes);
315 void * _link_allocate(
void) pool_nothrow {
316 if (depth >= MEMPOOL_FALLBACK_DEPTH)
return mempool_callbacks::allocate(bytes);
318 _link =
new(mempool_callbacks::allocate(
sizeof(memory_pool_no_fullflag<bytes, size>))) memory_pool_no_fullflag<bytes, size>();
319 _link -> depth = depth + 1;
321 return _link -> allocate();
326 char memoryPool_start[size * bytes];
327 char * memoryPool_end;
328 bool used_start[size];
330 bool * runningPointer;
331 memory_pool_no_fullflag<bytes, size> * _link;
335 template <
size_t bytes,
size_t size>
336 class memory_pool :
public memory_pool_no_fullflag<bytes, size> {
338 memory_pool<bytes, size>() :
339 memory_pool_no_fullflag<bytes, size>(),
342 virtual ~memory_pool(
void){}
344 inline void * allocate(
void) pool_hot {
345 if (_full)
return mempool_callbacks::allocate(bytes);
346 return memory_pool_no_fullflag<bytes, size>::allocate();
349 inline void deallocate(
void * ptr) pool_hot {
351 return memory_pool_no_fullflag<bytes, size>::deallocate(ptr);
354 #ifdef MEMPOOL_PERFORMANCE_DEBUGGING
355 const char *
const getName(
void){
return "memory_pool"; }
359 memory_pool & operator = (
const memory_pool & other);
360 memory_pool(
const memory_pool & other);
364 template <
typename T,
size_t s>
friend class object_memory_pool;
369 #define new_object(pool, ctor) new (pool.allocate_noctor()) ctor //allows user to call a specific ctor on the object [ new_object(mypool, T(x, y)) ]
370 template <
typename T,
size_t size>
371 class object_memory_pool {
373 inline size_t load(
void) const pool_nothrow {
377 virtual ~object_memory_pool() pool_nothrow { }
379 inline T * allocate(
void) pool_hot {
return new (_pool.allocate()) T(); }
380 inline void * allocate_noctor(
void) pool_nothrow {
return _pool.allocate(); }
382 inline void deallocate(T * ptr) pool_hot {
384 _pool.deallocate(ptr);
387 inline memory_pool<sizeof(T), size> * contains(T * ptr)
const pool_hot {
388 return _pool.contains((
void*)ptr);
391 inline T * alloc_nofallback() pool_hot {
392 if (
void * res = _pool.allocate_nofallback()){
393 return new (res) T();
398 inline void deallocate_nofallback(T * ptr) pool_hot {
400 _pool.deallocate_nofallback(ptr);
402 #ifdef MEMPOOL_PERFORMANCE_DEBUGGING
403 const std::string dump(
void){
return _pool.dump(); }
406 memory_pool<sizeof(T), size> _pool;
410 #define MEMPOOL_TEMPLATE_PAIR(x) size_t bytes ## x , size_t count ## x
411 #define MEMPOOL_ALLOC_CHECK(x) if (bytes <= bytes ## x ){ if (void * res = (_pool ## x).allocate_nofallback()) return res; }
412 #define MEMPOOL_DEALLOC_CHECK(x) if (memory_pool_no_fullflag< bytes ## x , count ## x > * container = (_pool ## x).contains(ptr)){ container -> deallocate_nofallback(ptr); return; }
413 #define MEMPOOL_MEMBER_POOL(x) memory_pool< bytes ## x , count ## x > _pool ## x;
415 #define MEMPOOL_REALLOC_CHECK(x)\
416 if (memory_pool_no_fullflag< bytes ## x , count ## x > * container = (_pool ## x).contains(ptr)){\
417 if (bytes <= bytes ## x) return ptr;\
418 void * newvalue = allocate(bytes);\
419 std::memcpy(newvalue, ptr, bytes ## x);\
420 container -> deallocate_nofallback(ptr);\
425 #ifdef MEMPOOL_DETERMINE_DISTRIBUTION
428 #define MEMPOOL_ALLOC_METHOD(number, code)\
429 bucket_pool_ ## number (void) : _profile_on_delete(0) { }\
430 ~bucket_pool_ ## number (void) { \
431 if (_profile_on_delete){ \
432 dump_atonce(_profile_on_delete, _profile_on_delete / 40); \
433 dump_template(_profile_on_delete); \
436 void * allocate(size_t bytes) pool_hot {\
437 if (mapping.find(bytes) != mapping.end()){\
439 ++current_mapping[bytes];\
440 if (current_mapping[bytes] > max_mapping[bytes]) max_mapping[bytes] = current_mapping[bytes];\
443 max_mapping[bytes] = 1;\
444 current_mapping[bytes] = 1;\
446 void * res = mempool_callbacks::allocate(bytes);\
447 mem_mapping[res] = bytes;\
450 #define MEMPOOL_DEALLOC_METHOD(code)\
451 void deallocate(void * ptr) pool_hot {\
452 --current_mapping[mem_mapping[ptr]];\
453 mem_mapping.erase(ptr);\
454 mempool_callbacks::deallocate(ptr);\
457 #define MEMPOOL_ANALYZERS(macro_count)\
458 inline size_t _max(size_t one, size_t two){ return (one > two) ? one : two; }\
459 void dump_total(size_t max, size_t sep = 16, size_t tlen = 30){\
460 std::cout << "-------- Total --------" << std::endl;\
461 size_t max_amount = 0;\
462 for(size_t i = 0; i < max;){\
464 for(size_t j = 0; j < sep; ++j, ++i){\
465 if (mapping.find(i) != mapping.end()){\
466 amount += mapping[i];\
469 if (amount > max_amount) max_amount = amount;\
471 float scalar = ((float)max_amount) / ((float)tlen);\
473 for(size_t i = 0; i < max;){\
475 for(size_t j = 0; j < sep; ++j, ++i){\
476 if (mapping.find(i) != mapping.end()){\
477 amount += mapping[i];\
481 if (i < 10) std::cout << ' ';\
482 if (i < 100) std::cout << ' ';\
483 if (i < 1000) std::cout << ' ';\
484 if (i < 10000) std::cout << ' ';\
485 std::cout << i << ':';\
487 for(size_t j = 0; j < (size_t)((float)amount / scalar); ++j){\
490 std::cout << '(' << amount << ')' << std::endl;\
494 void dump_atonce(size_t max, size_t sep = 16, size_t tlen = 30){\
495 std::cout << "------ Distribution for \"" << _str << "\" ------" << std::endl;\
496 size_t max_amount = 0;\
497 for(size_t i = 0; i < max;){\
499 for(size_t j = 0; j < sep; ++j, ++i){\
500 if (max_mapping.find(i) != max_mapping.end()){\
501 amount += max_mapping[i];\
504 if (amount > max_amount) max_amount = amount;\
506 float scalar = ((float)max_amount) / ((float)tlen);\
508 for(size_t i = 0; i < max;){\
510 for(size_t j = 0; j < sep; ++j, ++i){\
511 if (max_mapping.find(i) != max_mapping.end()){\
512 amount += max_mapping[i];\
516 if (i < 10) std::cout << ' ';\
517 if (i < 100) std::cout << ' ';\
518 if (i < 1000) std::cout << ' ';\
519 if (i < 10000) std::cout << ' ';\
520 std::cout << i << ':';\
522 for(size_t j = 0; j < (size_t)((float)amount / scalar); ++j){\
525 std::cout << '(' << amount << ')' << std::endl;\
529 void dump_template(size_t max){\
530 std::cout << "Recommended Template for \"" << _str << "\" = ";\
531 size_t total_at_once = 0;\
533 for(size_t i = 0; i < max; ++i){\
534 if (max_mapping.find(i) != max_mapping.end()){\
535 total_at_once += max_mapping[i];\
541 size_t total_at_once_part = total_at_once / macro_count;\
543 size_t totalsofar = 0;\
545 for(size_t i = 0; ((i < max) && (count < (macro_count -1))); ++i){\
546 if (max_mapping.find(i) != max_mapping.end()){\
547 current += max_mapping[i];\
548 totalsofar += max_mapping[i];\
549 if (current > total_at_once_part){\
550 std::cout << (i - 1) << ", " << (size_t)(((float)current - max_mapping[i]) * (MEMPOOL_DETERMINE_SCALAR)) << ", ";\
551 current = max_mapping[i];\
556 std::cout << max << ", " << _max((size_t)((float)(total_at_once - totalsofar) * (MEMPOOL_DETERMINE_SCALAR)), total_at_once_part / 2) << '>' << std::endl;\
559 inline void profile_on_delete(size_t var, const std::string & str){ _profile_on_delete = var; _str = str; }
561 #define MEMPOOL_MEMBERS(code)\
562 std::map<size_t, size_t> mapping;\
563 std::map<size_t, size_t> current_mapping;\
564 std::map<size_t, size_t> max_mapping;\
565 std::map<void *, size_t> mem_mapping;\
566 size_t _profile_on_delete;\
568 #define MEMPOOL_LOAD(number, code) inline size_t * load(void) const pool_nothrow { static size_t _load[number] = {0}; return &_load[0]; }
570 #define MEMPOOL_ALLOC_METHOD(number, code)\
571 void * allocate(size_t bytes) pool_hot {\
573 return mempool_callbacks::allocate(bytes);\
575 #define MEMPOOL_DEALLOC_METHOD(code)\
576 void deallocate(void * ptr) pool_hot {\
578 mempool_callbacks::deallocate(ptr);\
580 #define MEMPOOL_ANALYZERS(macro_count)
581 #define MEMPOOL_MEMBERS(code) code
582 #define MEMPOOL_LOAD(number, code) inline size_t * load(void) const pool_nothrow { static size_t _load[number]; code return &_load[0]; }
586 MEMPOOL_TEMPLATE_PAIR(1),
587 MEMPOOL_TEMPLATE_PAIR(2)>
588 class bucket_pool_2 {
590 MEMPOOL_ALLOC_METHOD(
592 MEMPOOL_ALLOC_CHECK(1)
593 MEMPOOL_ALLOC_CHECK(2)
595 void * reallocate(
void * ptr,
size_t bytes){
596 MEMPOOL_REALLOC_CHECK(1)
597 MEMPOOL_REALLOC_CHECK(2)
601 _load[0] = _pool1.load();
602 _load[1] = _pool2.load();
604 MEMPOOL_DEALLOC_METHOD(
605 MEMPOOL_DEALLOC_CHECK(1)
606 MEMPOOL_DEALLOC_CHECK(2)
611 MEMPOOL_MEMBER_POOL(1)
612 MEMPOOL_MEMBER_POOL(2)
617 MEMPOOL_TEMPLATE_PAIR(1),
618 MEMPOOL_TEMPLATE_PAIR(2),
619 MEMPOOL_TEMPLATE_PAIR(3)>
620 class bucket_pool_3 {
622 MEMPOOL_ALLOC_METHOD(
624 MEMPOOL_ALLOC_CHECK(1)
625 MEMPOOL_ALLOC_CHECK(2)
626 MEMPOOL_ALLOC_CHECK(3)
628 void * reallocate(
void * ptr,
size_t bytes){
629 MEMPOOL_REALLOC_CHECK(1)
630 MEMPOOL_REALLOC_CHECK(2)
631 MEMPOOL_REALLOC_CHECK(3)
632 return mempool_callbacks::reallocate(ptr, bytes);
636 _load[0] = _pool1.load();
637 _load[1] = _pool2.load();
638 _load[2] = _pool3.load();
640 MEMPOOL_DEALLOC_METHOD(
641 MEMPOOL_DEALLOC_CHECK(1)
642 MEMPOOL_DEALLOC_CHECK(2)
643 MEMPOOL_DEALLOC_CHECK(3)
648 MEMPOOL_MEMBER_POOL(1)
649 MEMPOOL_MEMBER_POOL(2)
650 MEMPOOL_MEMBER_POOL(3)
655 MEMPOOL_TEMPLATE_PAIR(1),
656 MEMPOOL_TEMPLATE_PAIR(2),
657 MEMPOOL_TEMPLATE_PAIR(3),
658 MEMPOOL_TEMPLATE_PAIR(4)>
659 class bucket_pool_4 {
661 MEMPOOL_ALLOC_METHOD(
663 MEMPOOL_ALLOC_CHECK(1)
664 MEMPOOL_ALLOC_CHECK(2)
665 MEMPOOL_ALLOC_CHECK(3)
666 MEMPOOL_ALLOC_CHECK(4)
668 void * reallocate(
void * ptr,
size_t bytes){
669 MEMPOOL_REALLOC_CHECK(1)
670 MEMPOOL_REALLOC_CHECK(2)
671 MEMPOOL_REALLOC_CHECK(3)
672 MEMPOOL_REALLOC_CHECK(4)
673 return mempool_callbacks::reallocate(ptr, bytes);
677 _load[0] = _pool1.load();
678 _load[1] = _pool2.load();
679 _load[2] = _pool3.load();
680 _load[3] = _pool4.load();
682 MEMPOOL_DEALLOC_METHOD(
683 MEMPOOL_DEALLOC_CHECK(1)
684 MEMPOOL_DEALLOC_CHECK(2)
685 MEMPOOL_DEALLOC_CHECK(3)
686 MEMPOOL_DEALLOC_CHECK(4)
691 MEMPOOL_MEMBER_POOL(1)
692 MEMPOOL_MEMBER_POOL(2)
693 MEMPOOL_MEMBER_POOL(3)
694 MEMPOOL_MEMBER_POOL(4)
699 MEMPOOL_TEMPLATE_PAIR(1),
700 MEMPOOL_TEMPLATE_PAIR(2),
701 MEMPOOL_TEMPLATE_PAIR(3),
702 MEMPOOL_TEMPLATE_PAIR(4),
703 MEMPOOL_TEMPLATE_PAIR(5)>
704 class bucket_pool_5 {
706 MEMPOOL_ALLOC_METHOD(
708 MEMPOOL_ALLOC_CHECK(1)
709 MEMPOOL_ALLOC_CHECK(2)
710 MEMPOOL_ALLOC_CHECK(3)
711 MEMPOOL_ALLOC_CHECK(4)
712 MEMPOOL_ALLOC_CHECK(5)
714 void * reallocate(
void * ptr,
size_t bytes){
715 MEMPOOL_REALLOC_CHECK(1)
716 MEMPOOL_REALLOC_CHECK(2)
717 MEMPOOL_REALLOC_CHECK(3)
718 MEMPOOL_REALLOC_CHECK(4)
719 MEMPOOL_REALLOC_CHECK(5)
720 return mempool_callbacks::reallocate(ptr, bytes);
724 _load[0] = _pool1.load();
725 _load[1] = _pool2.load();
726 _load[2] = _pool3.load();
727 _load[3] = _pool4.load();
728 _load[4] = _pool5.load();
730 MEMPOOL_DEALLOC_METHOD(
731 MEMPOOL_DEALLOC_CHECK(1)
732 MEMPOOL_DEALLOC_CHECK(2)
733 MEMPOOL_DEALLOC_CHECK(3)
734 MEMPOOL_DEALLOC_CHECK(4)
735 MEMPOOL_DEALLOC_CHECK(5)
740 MEMPOOL_MEMBER_POOL(1)
741 MEMPOOL_MEMBER_POOL(2)
742 MEMPOOL_MEMBER_POOL(3)
743 MEMPOOL_MEMBER_POOL(4)
744 MEMPOOL_MEMBER_POOL(5)
749 MEMPOOL_TEMPLATE_PAIR(1),
750 MEMPOOL_TEMPLATE_PAIR(2),
751 MEMPOOL_TEMPLATE_PAIR(3),
752 MEMPOOL_TEMPLATE_PAIR(4),
753 MEMPOOL_TEMPLATE_PAIR(5),
754 MEMPOOL_TEMPLATE_PAIR(6)>
755 class bucket_pool_6 {
757 MEMPOOL_ALLOC_METHOD(
759 MEMPOOL_ALLOC_CHECK(1)
760 MEMPOOL_ALLOC_CHECK(2)
761 MEMPOOL_ALLOC_CHECK(3)
762 MEMPOOL_ALLOC_CHECK(4)
763 MEMPOOL_ALLOC_CHECK(5)
764 MEMPOOL_ALLOC_CHECK(6)
766 void * reallocate(
void * ptr,
size_t bytes){
767 MEMPOOL_REALLOC_CHECK(1)
768 MEMPOOL_REALLOC_CHECK(2)
769 MEMPOOL_REALLOC_CHECK(3)
770 MEMPOOL_REALLOC_CHECK(4)
771 MEMPOOL_REALLOC_CHECK(5)
772 MEMPOOL_REALLOC_CHECK(6)
773 return mempool_callbacks::reallocate(ptr, bytes);
777 _load[0] = _pool1.load();
778 _load[1] = _pool2.load();
779 _load[2] = _pool3.load();
780 _load[3] = _pool4.load();
781 _load[4] = _pool5.load();
782 _load[5] = _pool6.load();
784 MEMPOOL_DEALLOC_METHOD(
785 MEMPOOL_DEALLOC_CHECK(1)
786 MEMPOOL_DEALLOC_CHECK(2)
787 MEMPOOL_DEALLOC_CHECK(3)
788 MEMPOOL_DEALLOC_CHECK(4)
789 MEMPOOL_DEALLOC_CHECK(5)
790 MEMPOOL_DEALLOC_CHECK(6)
795 MEMPOOL_MEMBER_POOL(1)
796 MEMPOOL_MEMBER_POOL(2)
797 MEMPOOL_MEMBER_POOL(3)
798 MEMPOOL_MEMBER_POOL(4)
799 MEMPOOL_MEMBER_POOL(5)
800 MEMPOOL_MEMBER_POOL(6)
805 MEMPOOL_TEMPLATE_PAIR(1),
806 MEMPOOL_TEMPLATE_PAIR(2),
807 MEMPOOL_TEMPLATE_PAIR(3),
808 MEMPOOL_TEMPLATE_PAIR(4),
809 MEMPOOL_TEMPLATE_PAIR(5),
810 MEMPOOL_TEMPLATE_PAIR(6),
811 MEMPOOL_TEMPLATE_PAIR(7)>
812 class bucket_pool_7 {
814 MEMPOOL_ALLOC_METHOD(
816 MEMPOOL_ALLOC_CHECK(1)
817 MEMPOOL_ALLOC_CHECK(2)
818 MEMPOOL_ALLOC_CHECK(3)
819 MEMPOOL_ALLOC_CHECK(4)
820 MEMPOOL_ALLOC_CHECK(5)
821 MEMPOOL_ALLOC_CHECK(6)
822 MEMPOOL_ALLOC_CHECK(7)
824 void * reallocate(
void * ptr,
size_t bytes){
825 MEMPOOL_REALLOC_CHECK(1)
826 MEMPOOL_REALLOC_CHECK(2)
827 MEMPOOL_REALLOC_CHECK(3)
828 MEMPOOL_REALLOC_CHECK(4)
829 MEMPOOL_REALLOC_CHECK(5)
830 MEMPOOL_REALLOC_CHECK(6)
831 MEMPOOL_REALLOC_CHECK(7)
832 return mempool_callbacks::reallocate(ptr, bytes);
836 _load[0] = _pool1.load();
837 _load[1] = _pool2.load();
838 _load[2] = _pool3.load();
839 _load[3] = _pool4.load();
840 _load[4] = _pool5.load();
841 _load[5] = _pool6.load();
842 _load[6] = _pool7.load();
844 MEMPOOL_DEALLOC_METHOD(
845 MEMPOOL_DEALLOC_CHECK(1)
846 MEMPOOL_DEALLOC_CHECK(2)
847 MEMPOOL_DEALLOC_CHECK(3)
848 MEMPOOL_DEALLOC_CHECK(4)
849 MEMPOOL_DEALLOC_CHECK(5)
850 MEMPOOL_DEALLOC_CHECK(6)
851 MEMPOOL_DEALLOC_CHECK(7)
856 MEMPOOL_MEMBER_POOL(1)
857 MEMPOOL_MEMBER_POOL(2)
858 MEMPOOL_MEMBER_POOL(3)
859 MEMPOOL_MEMBER_POOL(4)
860 MEMPOOL_MEMBER_POOL(5)
861 MEMPOOL_MEMBER_POOL(6)
862 MEMPOOL_MEMBER_POOL(7)
867 MEMPOOL_TEMPLATE_PAIR(1),
868 MEMPOOL_TEMPLATE_PAIR(2),
869 MEMPOOL_TEMPLATE_PAIR(3),
870 MEMPOOL_TEMPLATE_PAIR(4),
871 MEMPOOL_TEMPLATE_PAIR(5),
872 MEMPOOL_TEMPLATE_PAIR(6),
873 MEMPOOL_TEMPLATE_PAIR(7),
874 MEMPOOL_TEMPLATE_PAIR(8)>
875 class bucket_pool_8 {
877 MEMPOOL_ALLOC_METHOD(
879 MEMPOOL_ALLOC_CHECK(1)
880 MEMPOOL_ALLOC_CHECK(2)
881 MEMPOOL_ALLOC_CHECK(3)
882 MEMPOOL_ALLOC_CHECK(4)
883 MEMPOOL_ALLOC_CHECK(5)
884 MEMPOOL_ALLOC_CHECK(6)
885 MEMPOOL_ALLOC_CHECK(7)
886 MEMPOOL_ALLOC_CHECK(8)
888 void * reallocate(
void * ptr,
size_t bytes){
889 MEMPOOL_REALLOC_CHECK(1)
890 MEMPOOL_REALLOC_CHECK(2)
891 MEMPOOL_REALLOC_CHECK(3)
892 MEMPOOL_REALLOC_CHECK(4)
893 MEMPOOL_REALLOC_CHECK(5)
894 MEMPOOL_REALLOC_CHECK(6)
895 MEMPOOL_REALLOC_CHECK(7)
896 MEMPOOL_REALLOC_CHECK(8)
897 return mempool_callbacks::reallocate(ptr, bytes);
901 _load[0] = _pool1.load();
902 _load[1] = _pool2.load();
903 _load[2] = _pool3.load();
904 _load[3] = _pool4.load();
905 _load[4] = _pool5.load();
906 _load[5] = _pool6.load();
907 _load[6] = _pool7.load();
908 _load[7] = _pool8.load();
910 MEMPOOL_DEALLOC_METHOD(
911 MEMPOOL_DEALLOC_CHECK(1)
912 MEMPOOL_DEALLOC_CHECK(2)
913 MEMPOOL_DEALLOC_CHECK(3)
914 MEMPOOL_DEALLOC_CHECK(4)
915 MEMPOOL_DEALLOC_CHECK(5)
916 MEMPOOL_DEALLOC_CHECK(6)
917 MEMPOOL_DEALLOC_CHECK(7)
918 MEMPOOL_DEALLOC_CHECK(8)
923 MEMPOOL_MEMBER_POOL(1)
924 MEMPOOL_MEMBER_POOL(2)
925 MEMPOOL_MEMBER_POOL(3)
926 MEMPOOL_MEMBER_POOL(4)
927 MEMPOOL_MEMBER_POOL(5)
928 MEMPOOL_MEMBER_POOL(6)
929 MEMPOOL_MEMBER_POOL(7)
930 MEMPOOL_MEMBER_POOL(8)
935 MEMPOOL_TEMPLATE_PAIR(1),
936 MEMPOOL_TEMPLATE_PAIR(2),
937 MEMPOOL_TEMPLATE_PAIR(3),
938 MEMPOOL_TEMPLATE_PAIR(4),
939 MEMPOOL_TEMPLATE_PAIR(5),
940 MEMPOOL_TEMPLATE_PAIR(6),
941 MEMPOOL_TEMPLATE_PAIR(7),
942 MEMPOOL_TEMPLATE_PAIR(8),
943 MEMPOOL_TEMPLATE_PAIR(9)>
944 class bucket_pool_9 {
946 MEMPOOL_ALLOC_METHOD(
948 MEMPOOL_ALLOC_CHECK(1)
949 MEMPOOL_ALLOC_CHECK(2)
950 MEMPOOL_ALLOC_CHECK(3)
951 MEMPOOL_ALLOC_CHECK(4)
952 MEMPOOL_ALLOC_CHECK(5)
953 MEMPOOL_ALLOC_CHECK(6)
954 MEMPOOL_ALLOC_CHECK(7)
955 MEMPOOL_ALLOC_CHECK(8)
956 MEMPOOL_ALLOC_CHECK(9)
958 void * reallocate(
void * ptr,
size_t bytes){
959 MEMPOOL_REALLOC_CHECK(1)
960 MEMPOOL_REALLOC_CHECK(2)
961 MEMPOOL_REALLOC_CHECK(3)
962 MEMPOOL_REALLOC_CHECK(4)
963 MEMPOOL_REALLOC_CHECK(5)
964 MEMPOOL_REALLOC_CHECK(6)
965 MEMPOOL_REALLOC_CHECK(7)
966 MEMPOOL_REALLOC_CHECK(8)
967 MEMPOOL_REALLOC_CHECK(9)
968 return mempool_callbacks::reallocate(ptr, bytes);
972 _load[0] = _pool1.load();
973 _load[1] = _pool2.load();
974 _load[2] = _pool3.load();
975 _load[3] = _pool4.load();
976 _load[4] = _pool5.load();
977 _load[5] = _pool6.load();
978 _load[6] = _pool7.load();
979 _load[7] = _pool8.load();
980 _load[8] = _pool9.load();
982 MEMPOOL_DEALLOC_METHOD(
983 MEMPOOL_DEALLOC_CHECK(1)
984 MEMPOOL_DEALLOC_CHECK(2)
985 MEMPOOL_DEALLOC_CHECK(3)
986 MEMPOOL_DEALLOC_CHECK(4)
987 MEMPOOL_DEALLOC_CHECK(5)
988 MEMPOOL_DEALLOC_CHECK(6)
989 MEMPOOL_DEALLOC_CHECK(7)
990 MEMPOOL_DEALLOC_CHECK(8)
991 MEMPOOL_DEALLOC_CHECK(9)
996 MEMPOOL_MEMBER_POOL(1)
997 MEMPOOL_MEMBER_POOL(2)
998 MEMPOOL_MEMBER_POOL(3)
999 MEMPOOL_MEMBER_POOL(4)
1000 MEMPOOL_MEMBER_POOL(5)
1001 MEMPOOL_MEMBER_POOL(6)
1002 MEMPOOL_MEMBER_POOL(7)
1003 MEMPOOL_MEMBER_POOL(8)
1004 MEMPOOL_MEMBER_POOL(9)
1009 MEMPOOL_TEMPLATE_PAIR(1),
1010 MEMPOOL_TEMPLATE_PAIR(2),
1011 MEMPOOL_TEMPLATE_PAIR(3),
1012 MEMPOOL_TEMPLATE_PAIR(4),
1013 MEMPOOL_TEMPLATE_PAIR(5),
1014 MEMPOOL_TEMPLATE_PAIR(6),
1015 MEMPOOL_TEMPLATE_PAIR(7),
1016 MEMPOOL_TEMPLATE_PAIR(8),
1017 MEMPOOL_TEMPLATE_PAIR(9),
1018 MEMPOOL_TEMPLATE_PAIR(10)>
1019 class bucket_pool_10 {
1021 MEMPOOL_ALLOC_METHOD(
1023 MEMPOOL_ALLOC_CHECK(1)
1024 MEMPOOL_ALLOC_CHECK(2)
1025 MEMPOOL_ALLOC_CHECK(3)
1026 MEMPOOL_ALLOC_CHECK(4)
1027 MEMPOOL_ALLOC_CHECK(5)
1028 MEMPOOL_ALLOC_CHECK(6)
1029 MEMPOOL_ALLOC_CHECK(7)
1030 MEMPOOL_ALLOC_CHECK(8)
1031 MEMPOOL_ALLOC_CHECK(9)
1032 MEMPOOL_ALLOC_CHECK(10)
1034 void * reallocate(
void * ptr,
size_t bytes){
1035 MEMPOOL_REALLOC_CHECK(1)
1036 MEMPOOL_REALLOC_CHECK(2)
1037 MEMPOOL_REALLOC_CHECK(3)
1038 MEMPOOL_REALLOC_CHECK(4)
1039 MEMPOOL_REALLOC_CHECK(5)
1040 MEMPOOL_REALLOC_CHECK(6)
1041 MEMPOOL_REALLOC_CHECK(7)
1042 MEMPOOL_REALLOC_CHECK(8)
1043 MEMPOOL_REALLOC_CHECK(9)
1044 MEMPOOL_REALLOC_CHECK(10)
1045 return mempool_callbacks::reallocate(ptr, bytes);
1049 _load[0] = _pool1.load();
1050 _load[1] = _pool2.load();
1051 _load[2] = _pool3.load();
1052 _load[3] = _pool4.load();
1053 _load[4] = _pool5.load();
1054 _load[5] = _pool6.load();
1055 _load[6] = _pool7.load();
1056 _load[7] = _pool8.load();
1057 _load[8] = _pool9.load();
1058 _load[9] = _pool10.load();
1060 MEMPOOL_DEALLOC_METHOD(
1061 MEMPOOL_DEALLOC_CHECK(1)
1062 MEMPOOL_DEALLOC_CHECK(2)
1063 MEMPOOL_DEALLOC_CHECK(3)
1064 MEMPOOL_DEALLOC_CHECK(4)
1065 MEMPOOL_DEALLOC_CHECK(5)
1066 MEMPOOL_DEALLOC_CHECK(6)
1067 MEMPOOL_DEALLOC_CHECK(7)
1068 MEMPOOL_DEALLOC_CHECK(8)
1069 MEMPOOL_DEALLOC_CHECK(9)
1070 MEMPOOL_DEALLOC_CHECK(10)
1072 MEMPOOL_ANALYZERS(10)
1075 MEMPOOL_MEMBER_POOL(1)
1076 MEMPOOL_MEMBER_POOL(2)
1077 MEMPOOL_MEMBER_POOL(3)
1078 MEMPOOL_MEMBER_POOL(4)
1079 MEMPOOL_MEMBER_POOL(5)
1080 MEMPOOL_MEMBER_POOL(6)
1081 MEMPOOL_MEMBER_POOL(7)
1082 MEMPOOL_MEMBER_POOL(8)
1083 MEMPOOL_MEMBER_POOL(9)
1084 MEMPOOL_MEMBER_POOL(10)