MCPcopy Create free account
hub / github.com/beefytech/Beef / background_threads_disable_single

Function background_threads_disable_single

BeefRT/JEMalloc/src/background_thread.c:232–269  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

230}
231
232static bool
233background_threads_disable_single(tsd_t *tsd, background_thread_info_t *info) {
234 if (info == &background_thread_info[0]) {
235 malloc_mutex_assert_owner(tsd_tsdn(tsd),
236 &background_thread_lock);
237 } else {
238 malloc_mutex_assert_not_owner(tsd_tsdn(tsd),
239 &background_thread_lock);
240 }
241
242 pre_reentrancy(tsd, NULL);
243 malloc_mutex_lock(tsd_tsdn(tsd), &info->mtx);
244 bool has_thread;
245 assert(info->state != background_thread_paused);
246 if (info->state == background_thread_started) {
247 has_thread = true;
248 info->state = background_thread_stopped;
249 pthread_cond_signal(&info->cond);
250 } else {
251 has_thread = false;
252 }
253 malloc_mutex_unlock(tsd_tsdn(tsd), &info->mtx);
254
255 if (!has_thread) {
256 post_reentrancy(tsd);
257 return false;
258 }
259 void *ret;
260 if (pthread_join(info->thread, &ret)) {
261 post_reentrancy(tsd);
262 return true;
263 }
264 assert(ret == NULL);
265 n_background_threads--;
266 post_reentrancy(tsd);
267
268 return false;
269}
270
271static void *background_thread_entry(void *ind_arg);
272

Callers 2

background_thread0_workFunction · 0.85

Calls 7

tsd_tsdnFunction · 0.85
pre_reentrancyFunction · 0.85
malloc_mutex_lockFunction · 0.85
malloc_mutex_unlockFunction · 0.85
post_reentrancyFunction · 0.85

Tested by

no test coverage detected