MCPcopy Create free account
hub / github.com/catboost/catboost / initialize_handler_pointers

Function initialize_handler_pointers

contrib/libs/tbb/src/tbb/allocator.cpp:134–152  ·  view source on GitHub ↗

Initialize the allocation/free handler pointers. Caller is responsible for ensuring this routine is called exactly once. The routine attempts to dynamically link with the TBB memory allocator. If that allocator is not found, it links to malloc and free. */

Source from the content-addressed store, hash-verified

132 The routine attempts to dynamically link with the TBB memory allocator.
133 If that allocator is not found, it links to malloc and free. */
134void initialize_handler_pointers() {
135 __TBB_ASSERT(allocate_handler == &initialize_allocate_handler, nullptr);
136 bool success = dynamic_link(MALLOCLIB_NAME, MallocLinkTable, 4);
137 if(!success) {
138 // If unsuccessful, set the handlers to the default routines.
139 // This must be done now, and not before FillDynamicLinks runs, because if other
140 // threads call the handlers, we want them to go through the DoOneTimeInitializations logic,
141 // which forces them to wait.
142 allocate_handler_unsafe = &std::malloc;
143 deallocate_handler = &std::free;
144 cache_aligned_allocate_handler_unsafe = &std_cache_aligned_allocate;
145 cache_aligned_deallocate_handler = &std_cache_aligned_deallocate;
146 }
147
148 allocate_handler.store(allocate_handler_unsafe, std::memory_order_release);
149 cache_aligned_allocate_handler.store(cache_aligned_allocate_handler_unsafe, std::memory_order_release);
150
151 PrintExtraVersionInfo( "ALLOCATOR", success?"scalable_malloc":"malloc" );
152}
153
154static std::once_flag initialization_state;
155void initialize_cache_aligned_allocator() {

Callers

nothing calls this directly

Calls 3

dynamic_linkFunction · 0.85
PrintExtraVersionInfoFunction · 0.85
storeMethod · 0.45

Tested by

no test coverage detected