Merge pull request #24394 from yulin-liang/grpc-ios-cpu

Increasing the number of available threads for iOS
pull/24416/head
yulin liang 4 years ago committed by GitHub
commit 8c5467cd4d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      src/core/lib/gpr/cpu_iphone.cc

@ -22,8 +22,16 @@
#ifdef GPR_CPU_IPHONE
/* Probably 2 instead of 1, but see comment on gpr_cpu_current_cpu. */
unsigned gpr_cpu_num_cores(void) { return 1; }
#include <sys/sysctl.h>
unsigned gpr_cpu_num_cores(void) {
size_t len;
unsigned int ncpu;
len = sizeof(ncpu);
sysctlbyname("hw.ncpu", &ncpu, &len, NULL, 0);
return ncpu;
}
/* Most code that's using this is using it to shard across work queues. So
unless profiling shows it's a problem or there appears a way to detect the

Loading…
Cancel
Save