38template<
typename TAllocator>
 
  110    void* 
Get( 
size_t size, 
size_t alignment, 
const type_info& dbgTypeInfo);
 
  112    void* 
Get( 
size_t size, 
size_t alignment 
ALIB_DBG(, 
const std::type_info& dbgTypeInfo) )
 
  123            ALIB_MESSAGE( 
"RTTRA", 
"Object type detected     : ", &dbgTypeInfo )
 
  125                "Struct RTTRAllocator cannot be used to recycle types with an alignment " 
  126                "smaller than {}. Requested: {}", 
alignof(
Node), alignment )
 
  131            if( !
stack.isEmpty() )
 
  133                #if ALIB_DEBUG_MEMORY 
  134                    ALIB_MESSAGE( 
"RTTRA", 
"Recycling object.    Type: ", &dbgTypeInfo )
 
  136                return reinterpret_cast<char*
>( 
stack.popFront() );
 
  145                "A different object was requested for allocation!\n" 
  146                "  Previous type : <{}>\n" 
  147                "  Requested type: <{}>\n" 
  148                "Note: This allocator may not be efficient when used.\n" 
  149                "      If this is a use case using a 'std' library container, this message indicates\n" 
  150                "      that a RTTRAllocator was shared between different container instantiations.\n" 
  151                "      If this is not the case, than an 'unusual' implementation of such C++ library may\n" 
  152                "      prevent this concept from working. See ALib manual for further information.",
 
  158            ALIB_MESSAGE( 
"RTTRA", 
"Allocating a different object type \"{}\"\n" 
  159                                   "  Note: This object cannot be recycled.", &dbgTypeInfo )
 
  164        #if ALIB_DEBUG_MEMORY 
  165            ALIB_MESSAGE( 
"RTTRA", 
"Allocating object.   Type: \"{}\"", &dbgTypeInfo )
 
  182    void* 
AllocUnrelated( 
size_t size, 
size_t alignment, 
const type_info& dbgTypeInfo);
 
  188            ALIB_MESSAGE( 
"RTTRA", 
"Allocating other.    Type: <{}>", &dbgTypeInfo )
 
  214    void Recycle( 
void* mem, 
size_t size, 
size_t alignment, 
const type_info& dbgTypeInfo );
 
  216    void Recycle( 
void* mem, 
size_t size, 
size_t alignment 
ALIB_DBG(, 
const std::type_info& dbgTypeInfo) )
 
  221            stack.pushFront( 
reinterpret_cast<Node*
>( mem ) );
 
  222            #if ALIB_DEBUG_MEMORY 
  223                ALIB_MESSAGE( 
"RTTRA", 
"Stacking object.     Type: ", &dbgTypeInfo )
 
  235                        "De-allocation before a first object allocation needed to detect recyclable type!\n" 
  236                        "  De-allocated object type: <{}>\n" 
  237                        "Note: This allocator may not be efficient when used.\n" 
  238                        "      If this is a use case using a 'std' library container, this message indicates\n" 
  239                        "      an 'unusual' implementation of such C++ standard library." 
  249                        "A different object for was requested for de-allocoation!\n" 
  250                        "  Previous type : <{}>\n" 
  251                        "  Requested type: <{}>\n" 
  252                        "Note: This allocator may not be efficient when used.\n" 
  253                        "      If this is a use case using a 'std' library container, this message indicates\n" 
  254                        "      that a RTTRAllocator was shared between different container instantiations.\n" 
  255                        "      If this is not the case, than an 'unusual' implementation of such C++ library may\n" 
  256                        "      prevent this concept from working. See ALib manual for further information" 
  282    void RecycleChunk( 
void* mem, 
size_t size, 
const type_info& dbgTypeInfo );
 
  284    void RecycleChunk( 
void* memUnaligned, 
size_t size 
ALIB_DBG(, 
const std::type_info& dbgTypeInfo) )
 
  288        if( !TAllocator::allowsMemSplit() )
 
  302                "De-allocation before a first object allocation needed to detect recyclable type!\n" 
  303                "  De-allocated object type: <{}>.\n" 
  304                "Note: If this recycler is used with a 'std' library container, this either\n" 
  305                "      indicates an 'unusual' implementation of such C++ standard library,\n" 
  306                "      or a manual shrink of the capacity without any prior object insertion.\n",
 
  317        size-= size_t(mem - 
reinterpret_cast<char*
>(memUnaligned));
 
  320        ALIB_DBG( 
size_t cntStackedObjects= 0; )
 
  323            stack.pushFront( 
reinterpret_cast<Node*
>( mem ) );
 
  330            if( cntStackedObjects > 0 )
 
  333                "De-allocated chunk's size is smaller than detected object size.\n" 
  334                "  Deallocated object: Type: <{}>\n" 
  336                "  Detected object:    Type: <{}>\n" 
  337                "                      Size: {} bytes, alignment: {}\n" 
  338                "Note: If this recycler is used with a <std::unordered_map> or <std::unordered_set>,\n" 
  339                "      this message may be eliminated by reserving a reasonable initial bucket size.",
 
  345        #if ALIB_DEBUG_MEMORY 
  347               "Stacking {} objects from de-allocated memory of size {} (lost {} bytes).\n" 
  348               "Deallocated type: {}", cntStackedObjects, origSize,
 
 
#define ALIB_MESSAGE(domain,...)
#define ALIB_WARNING(domain,...)
#define ALIB_ASSERT_ERROR(cond, domain,...)
#define ALIB_DEBUG_MEMORY
@ Get
Denotes to search data.
AllocatorInterface< TAllocator > AI() const noexcept
TAllocator & GetAllocator() const noexcept
AllocatorMember()=delete
Deleted default constructor. (The allocator has to be given with construction)
void * AllocUnrelated(size_t size, size_t alignment, const type_info &dbgTypeInfo)
bool dbgWarnDeallocationPriorToAllocation
void * Get(size_t size, size_t alignment, const type_info &dbgTypeInfo)
size_t detectedObjectSize
The object size of recyclables. Will be detected with the first invocation of Get.
void RecycleChunk(void *mem, size_t size, const type_info &dbgTypeInfo)
RTTRAllocator(TAllocator &pAllocator) noexcept
void Recycle(void *mem, size_t size, size_t alignment, const type_info &dbgTypeInfo)
SidiListHook< Node > stack
List of destructed objects available for recycling.
bool dbgWarnRecycleChunkPriorToAllocation
size_t detectedObjectAlignment
The required object alignment. Will be detected with the first invocation of Get.
bool dbgWarnDifferentObjectTypeDealloc
const std::type_info * dbgDetectedObjectTypeInfo
AllocatorMember< TAllocator > allocBase
The allocator type that TAllocator specifies.
bool dbgWarnDifferentObjectTypeAlloc
SidiNodeBase() noexcept=default