MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / malloc_init_hard_needed

Function malloc_init_hard_needed

deps/memkind/src/jemalloc/src/jemalloc.c:1194–1218  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1192}
1193
1194static bool
1195malloc_init_hard_needed(void) {
1196 if (malloc_initialized() || (IS_INITIALIZER && malloc_init_state ==
1197 malloc_init_recursible)) {
1198 /*
1199 * Another thread initialized the allocator before this one
1200 * acquired init_lock, or this thread is the initializing
1201 * thread, and it is recursively allocating.
1202 */
1203 return false;
1204 }
1205#ifdef JEMALLOC_THREADED_INIT
1206 if (malloc_initializer != NO_INITIALIZER && !IS_INITIALIZER) {
1207 /* Busy-wait until the initializing thread completes. */
1208 spin_t spinner = SPIN_INITIALIZER;
1209 do {
1210 malloc_mutex_unlock(TSDN_NULL, &init_lock);
1211 spin_adaptive(&spinner);
1212 malloc_mutex_lock(TSDN_NULL, &init_lock);
1213 } while (!malloc_initialized());
1214 return false;
1215 }
1216#endif
1217 return true;
1218}
1219
1220static bool
1221malloc_init_hard_a0_locked() {

Callers 1

malloc_init_hardFunction · 0.70

Calls 4

malloc_initializedFunction · 0.70
malloc_mutex_unlockFunction · 0.50
spin_adaptiveFunction · 0.50
malloc_mutex_lockFunction · 0.50

Tested by

no test coverage detected