diff options
author | Qi Wang <interwq@gwu.edu> | 2017-10-05 21:56:49 (GMT) |
---|---|---|
committer | Qi Wang <interwq@gmail.com> | 2017-10-06 05:57:56 (GMT) |
commit | 7e74093c96c019ce52aee9a03fc745647d79ca5f (patch) | |
tree | 712b31c8d1dd771b53a860ea3939545e649758d0 | |
parent | a2e6eb2c226ff63397220517883e13717f97da05 (diff) | |
download | jemalloc-dev.zip jemalloc-dev.tar.gz jemalloc-dev.tar.bz2 |
Set isthreaded manually.dev
Avoid relying pthread_once which creates dependency during init.
-rw-r--r-- | src/background_thread.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/background_thread.c b/src/background_thread.c index 609be52..6baff22 100644 --- a/src/background_thread.c +++ b/src/background_thread.c @@ -30,19 +30,20 @@ bool can_enable_background_thread; static int (*pthread_create_fptr)(pthread_t *__restrict, const pthread_attr_t *, void *(*)(void *), void *__restrict); -static pthread_once_t once_control = PTHREAD_ONCE_INIT; static void -pthread_create_wrapper_once(void) { +pthread_create_wrapper_init(void) { #ifdef JEMALLOC_LAZY_LOCK - isthreaded = true; + if (!isthreaded) { + isthreaded = true; + } #endif } int pthread_create_wrapper(pthread_t *__restrict thread, const pthread_attr_t *attr, void *(*start_routine)(void *), void *__restrict arg) { - pthread_once(&once_control, pthread_create_wrapper_once); + pthread_create_wrapper_init(); return pthread_create_fptr(thread, attr, start_routine, arg); } @@ -805,7 +806,7 @@ void background_thread_ctl_init(tsdn_t *tsdn) { malloc_mutex_assert_not_owner(tsdn, &background_thread_lock); #ifdef JEMALLOC_PTHREAD_CREATE_WRAPPER - pthread_once(&once_control, pthread_create_wrapper_once); + pthread_create_wrapper_init(); #endif } |