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

Function malloc_init_hard_needed

deps/jemalloc/src/jemalloc.c:1452–1476  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1450#undef MALLOC_CONF_NSOURCES
1451
1452static bool
1453malloc_init_hard_needed(void) {
1454 if (malloc_initialized() || (IS_INITIALIZER && malloc_init_state ==
1455 malloc_init_recursible)) {
1456 /*
1457 * Another thread initialized the allocator before this one
1458 * acquired init_lock, or this thread is the initializing
1459 * thread, and it is recursively allocating.
1460 */
1461 return false;
1462 }
1463#ifdef JEMALLOC_THREADED_INIT
1464 if (malloc_initializer != NO_INITIALIZER && !IS_INITIALIZER) {
1465 /* Busy-wait until the initializing thread completes. */
1466 spin_t spinner = SPIN_INITIALIZER;
1467 do {
1468 malloc_mutex_unlock(TSDN_NULL, &init_lock);
1469 spin_adaptive(&spinner);
1470 malloc_mutex_lock(TSDN_NULL, &init_lock);
1471 } while (!malloc_initialized());
1472 return false;
1473 }
1474#endif
1475 return true;
1476}
1477
1478static bool
1479malloc_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