Merge pull request #1 from nicolasnoble/kwasi-format

PR fix
pull/13173/head
kwasimensah 7 years ago committed by GitHub
commit 36817d90c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      src/core/lib/support/cpu_posix.cc

@ -54,8 +54,8 @@ unsigned gpr_cpu_current_cpu(void) {
most code that's using this is using it to shard across work queues though, most code that's using this is using it to shard across work queues though,
so here we use thread identity instead to achieve a similar though not so here we use thread identity instead to achieve a similar though not
identical effect */ identical effect */
static auto DeleteValue = [](void *value_ptr) { static auto DeleteValue = [](void* value_ptr) {
unsigned int *value = static_cast<unsigned int *>(value_ptr); unsigned int* value = static_cast<unsigned int*>(value_ptr);
if (value) { if (value) {
gpr_free(value); gpr_free(value);
} }
@ -66,11 +66,11 @@ unsigned gpr_cpu_current_cpu(void) {
// pthread_t isn't portably defined to map to an integral type. So keep track // pthread_t isn't portably defined to map to an integral type. So keep track
// of thread identity explicitly so hashing works reliably. // of thread identity explicitly so hashing works reliably.
static std::atomic<unsigned int> thread_counter(0); static std::atomic<unsigned int> thread_counter(0);
unsigned int *thread_id = unsigned int* thread_id =
static_cast<unsigned int *>(pthread_getspecific(thread_id_key)); static_cast<unsigned int*>(pthread_getspecific(thread_id_key));
if (thread_id == nullptr) { 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)));
*thread_id = thread_counter++; *thread_id = thread_counter++;
pthread_setspecific(thread_id_key, thread_id); pthread_setspecific(thread_id_key, thread_id);
} }

Loading…
Cancel
Save