| 503 | } |
| 504 | |
| 505 | static void * |
| 506 | background_thread_entry(void *ind_arg) { |
| 507 | unsigned thread_ind = (unsigned)(uintptr_t)ind_arg; |
| 508 | assert(thread_ind < max_background_threads); |
| 509 | #ifdef JEMALLOC_HAVE_PTHREAD_SETNAME_NP |
| 510 | pthread_setname_np(pthread_self(), "jemalloc_bg_thd"); |
| 511 | #elif defined(__FreeBSD__) |
| 512 | pthread_set_name_np(pthread_self(), "jemalloc_bg_thd"); |
| 513 | #endif |
| 514 | if (opt_percpu_arena != percpu_arena_disabled) { |
| 515 | set_current_thread_affinity((int)thread_ind); |
| 516 | } |
| 517 | /* |
| 518 | * Start periodic background work. We use internal tsd which avoids |
| 519 | * side effects, for example triggering new arena creation (which in |
| 520 | * turn triggers another background thread creation). |
| 521 | */ |
| 522 | background_work(tsd_internal_fetch(), thread_ind); |
| 523 | assert(pthread_equal(pthread_self(), |
| 524 | background_thread_info[thread_ind].thread)); |
| 525 | |
| 526 | return NULL; |
| 527 | } |
| 528 | |
| 529 | static void |
| 530 | background_thread_init(tsd_t *tsd, background_thread_info_t *info) { |
nothing calls this directly
no test coverage detected