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

Function background_threads_disable_single

deps/jemalloc/src/background_thread.c:310–347  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

308}
309
310static bool
311background_threads_disable_single(tsd_t *tsd, background_thread_info_t *info) {
312 if (info == &background_thread_info[0]) {
313 malloc_mutex_assert_owner(tsd_tsdn(tsd),
314 &background_thread_lock);
315 } else {
316 malloc_mutex_assert_not_owner(tsd_tsdn(tsd),
317 &background_thread_lock);
318 }
319
320 pre_reentrancy(tsd, NULL);
321 malloc_mutex_lock(tsd_tsdn(tsd), &info->mtx);
322 bool has_thread;
323 assert(info->state != background_thread_paused);
324 if (info->state == background_thread_started) {
325 has_thread = true;
326 info->state = background_thread_stopped;
327 pthread_cond_signal(&info->cond);
328 } else {
329 has_thread = false;
330 }
331 malloc_mutex_unlock(tsd_tsdn(tsd), &info->mtx);
332
333 if (!has_thread) {
334 post_reentrancy(tsd);
335 return false;
336 }
337 void *ret;
338 if (pthread_join(info->thread, &ret)) {
339 post_reentrancy(tsd);
340 return true;
341 }
342 assert(ret == NULL);
343 n_background_threads--;
344 post_reentrancy(tsd);
345
346 return false;
347}
348
349static void *background_thread_entry(void *ind_arg);
350

Callers 2

background_thread0_workFunction · 0.70

Calls 7

tsd_tsdnFunction · 0.50
pre_reentrancyFunction · 0.50
malloc_mutex_lockFunction · 0.50
malloc_mutex_unlockFunction · 0.50
post_reentrancyFunction · 0.50

Tested by

no test coverage detected