8#if !defined(ALIB_C20_MODULES) || ((ALIB_C20_MODULES != 0) && (ALIB_C20_MODULES != 1))
9# error "Symbol ALIB_C20_MODULES has to be given to the compiler as either 0 or 1"
16#if ALIB_MONOMEM && ALIB_CONTAINERS
19#if ALIB_DEBUG && (!ALIB_MONOMEM || !ALIB_CONTAINERS )
20# include <unordered_map>
21# include <unordered_set>
30# if ALIB_DEBUG && ALIB_MONOMEM && ALIB_CONTAINERS
37# if ALIB_DEBUG && ALIB_MONOMEM && ALIB_CONTAINERS
49#if ALIB_MONOMEM && ALIB_CONTAINERS
51 CustomFunctionKey, CustomFunctionMapped,
55std::unordered_map< CustomFunctionKey, CustomFunctionMapped,
57 CustomFunctionEqualTo > customFunctionMap;
62#if ALIB_MONOMEM && ALIB_CONTAINERS
67 std::unordered_set< lang::TypeFunctors::Key , lang::TypeFunctors::Hash, lang::TypeFunctors::EqualTo> DbgKnownCustomFunctions;
68 std::unordered_map< lang::TypeFunctors::Key, detail::VTable*, lang::TypeFunctors::Hash, lang::TypeFunctors::EqualTo> DbgKnownVTables;
69 std::unordered_map< lang::TypeFunctors::Key, detail::VTable*, lang::TypeFunctors::Hash, lang::TypeFunctors::EqualTo> DbgKnownVTablesArray;
73void DbgLockMaps(
bool doLock )
75 #if ALIB_SINGLE_THREADED
80 ALIB_DBG(dbgLock.Dbg.Name=
"DbgBoxing";)
98#if (ALIB_MONOMEM && ALIB_CONTAINERS && ALIB_DEBUG)
101 #if ALIB_MONOMEM && ALIB_DEBUG_BOXING
102 debug::DbgKnownCustomFunctions.Reset();
103 debug::DbgKnownVTables .Reset();
104 debug::DbgKnownVTablesArray .Reset();
106 customFunctionMap .Reset();
113#if ALIB_MONOMEM && ALIB_CONTAINERS
114 auto it= customFunctionMap.Find( CustomFunctionKey(
this, rtti) );
116 auto it= customFunctionMap.find( CustomFunctionKey(
this, rtti) );
118 if ( it != customFunctionMap.end() )
121 ++it->second.DbgCntInvocations; )
122 return it->second.Implementation;
129 #if ALIB_DEBUG_BOXING
130 debug::DbgLockMaps(
true);
132 debug::DbgKnownCustomFunctions.InsertIfNotExistent( &rtti );
134 debug::DbgKnownCustomFunctions.emplace( &rtti );
136 debug::DbgLockMaps(
false);
140 #if ALIB_MONOMEM && ALIB_CONTAINERS
141 customFunctionMap.InsertOrAssign( CustomFunctionKey(
this, rtti), CustomFunctionMapped(impl) );
143 if( customFunctionMap.size() == 0 )
144 customFunctionMap.reserve( 50 );
145 customFunctionMap.insert_or_assign( CustomFunctionKey(
this, rtti), CustomFunctionMapped(impl) );
163 std::vector<detail::VTable*> result;
165 result.reserve(
size_t(
166 DbgKnownVTables .Size()
167 + DbgKnownVTablesArray.Size() ) );
169 result.reserve( DbgKnownVTables .size()
170 + DbgKnownVTablesArray.size() );
173 for(
int type= 0 ; type < 2 ; ++type )
175 auto& map= type == 0 ? DbgKnownVTables
176 : DbgKnownVTablesArray;
177 for(
auto it= map.begin() ; it!= map.end() ; ++it )
178 result.emplace_back( it->second );
187 std::vector<std::pair<const std::type_info*,uinteger>> result;
196 debug::DbgLockMaps(
true);
198 for (
auto* typeIt : debug::DbgKnownCustomFunctions )
201 auto usage= (std::numeric_limits<uinteger>::max)();
208 if( implIt != customFunctionMap.end() )
209 usage= implIt->second.DbgCntInvocations;
211 result.emplace_back( typeIt, usage );
214 debug::DbgLockMaps(
false);
220 std::vector<std::pair<const std::type_info*,uinteger>>& output )
233 for(
auto funcIt= customFunctionMap.begin() ; funcIt != customFunctionMap.end() ; ++funcIt )
234 if( funcIt->first.Parent == &functionTable )
235 output.emplace_back( &funcIt->first.Type , funcIt->second.DbgCntInvocations );
#define IF_ALIB_THREADS(...)
#define IF_ALIB_MONOMEM(...)
#define ALIB_CALLER_PRUNED
ALIB_DLL std::vector< std::pair< const std::type_info *, uinteger > > GetKnownFunctionTypes()
ALIB_DLL std::vector< detail::VTable * > GetKnownVTables()
ALIB_DLL void getFunctionTypes(const detail::FunctionTable &input, std::vector< std::pair< const std::type_info *, uinteger > > &output)
This namespace implements internals of namespace alib::boxing.
FunctionTable DEFAULT_FUNCTIONS
The default box-functions set.
ALIB_DLL TMonoAllocator< lang::HeapAllocator > GLOBAL_ALLOCATOR
containers::HashSet< TAllocator, T, THash, TEqual, THashCaching, TRecycling > HashSet
Type alias in namespace alib. See type definition alib::containers::HashSet.
containers::HashMap< TAllocator, TKey, TMapped, THash, TEqual, THashCaching, TRecycling > HashMap
Type alias in namespace alib.
monomem::TMonoAllocator< lang::HeapAllocator > MonoAllocator
threads::RecursiveLock RecursiveLock
Type alias in namespace alib.
ALIB_DLL void setCustom(const std::type_info &rtti, void *implementation)
uinteger DbgCntInvocationsFHashcode
Debug-compilation counter for the number of invocations.
uinteger DbgCntInvocationsFIsTrue
Debug-compilation counter for the number of invocations.
FIsNotNull::Signature fIsNotNull
Entry for built-in function FIsNotNull.
uinteger DbgCntInvocationsFIsLess
Debug-compilation counter for the number of invocations.
FIsTrue::Signature fIsTrue
Entry for built-in function FIsTrue.
FIsLess::Signature fIsLess
Entry for built-in function FIsLess.
ALIB_DLL void * getCustom(const std::type_info &rtti, bool isInvocation) const
FEquals::Signature fEquals
Entry for built-in function FEquals.
uinteger DbgCntInvocationsFIsNotNull
Debug-compilation counter for the number of invocations.
uinteger DbgCntInvocationsFEquals
Debug-compilation counter for the number of invocations.
FClone::Signature fClone
Entry for built-in function FClone.
uinteger DbgCntInvocationsFClone
Debug-compilation counter for the number of invocations.
FHashcode::Signature fHashcode
Entry for built-in function FHashcode.
static ALIB_DLL void Shutdown()
Needs to be called only in debug versions to shut down internal hashtables cleanly.