|
|
|
@ -49,7 +49,7 @@ unsigned gpr_cpu_num_cores(void) { |
|
|
|
|
return (unsigned)ncpus; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void delete_thread_id_key(void *value) { |
|
|
|
|
static void delete_thread_id_key(void* value) { |
|
|
|
|
if (value) { |
|
|
|
|
gpr_free(value); |
|
|
|
|
} |
|
|
|
@ -68,10 +68,10 @@ unsigned gpr_cpu_current_cpu(void) { |
|
|
|
|
static gpr_once once = GPR_ONCE_INIT; |
|
|
|
|
gpr_once_init(&once, init_thread_id_key); |
|
|
|
|
|
|
|
|
|
unsigned int *thread_id = |
|
|
|
|
static_cast<unsigned int *>(pthread_getspecific(thread_id_key)); |
|
|
|
|
unsigned int* thread_id = |
|
|
|
|
static_cast<unsigned int*>(pthread_getspecific(thread_id_key)); |
|
|
|
|
if (thread_id == nullptr) { |
|
|
|
|
thread_id = static_cast<unsigned int *>(gpr_malloc(sizeof(unsigned int))); |
|
|
|
|
thread_id = static_cast<unsigned int*>(gpr_malloc(sizeof(unsigned int))); |
|
|
|
|
pthread_setspecific(thread_id_key, thread_id); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|