|
|
@ -37,14 +37,15 @@ |
|
|
|
#include <grpc/support/log.h> |
|
|
|
#include <grpc/support/log.h> |
|
|
|
#include <grpc/support/port_platform.h> |
|
|
|
#include <grpc/support/port_platform.h> |
|
|
|
|
|
|
|
|
|
|
|
namespace grpc { |
|
|
|
|
|
|
|
namespace testing { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef GPR_CPU_LINUX |
|
|
|
#ifdef GPR_CPU_LINUX |
|
|
|
#ifndef _GNU_SOURCE |
|
|
|
#ifndef _GNU_SOURCE |
|
|
|
#define _GNU_SOURCE |
|
|
|
#define _GNU_SOURCE |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
#include <sched.h> |
|
|
|
#include <sched.h> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace grpc { |
|
|
|
|
|
|
|
namespace testing { |
|
|
|
|
|
|
|
|
|
|
|
int LimitCores(const int* cores, int cores_size) { |
|
|
|
int LimitCores(const int* cores, int cores_size) { |
|
|
|
const int num_cores = gpr_cpu_num_cores(); |
|
|
|
const int num_cores = gpr_cpu_num_cores(); |
|
|
|
int cores_set = 0; |
|
|
|
int cores_set = 0; |
|
|
@ -71,9 +72,16 @@ int LimitCores(const int* cores, int cores_size) { |
|
|
|
CPU_FREE(cpup); |
|
|
|
CPU_FREE(cpup); |
|
|
|
return cores_set; |
|
|
|
return cores_set; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace testing
|
|
|
|
|
|
|
|
} // namespace grpc
|
|
|
|
#else |
|
|
|
#else |
|
|
|
|
|
|
|
namespace grpc { |
|
|
|
|
|
|
|
namespace testing { |
|
|
|
|
|
|
|
|
|
|
|
// LimitCores is not currently supported for non-Linux platforms
|
|
|
|
// LimitCores is not currently supported for non-Linux platforms
|
|
|
|
int LimitCores(const int*, int) { return gpr_cpu_num_cores(); } |
|
|
|
int LimitCores(const int*, int) { return gpr_cpu_num_cores(); } |
|
|
|
#endif |
|
|
|
|
|
|
|
} // namespace testing
|
|
|
|
} // namespace testing
|
|
|
|
} // namespace grpc
|
|
|
|
} // namespace grpc
|
|
|
|
|
|
|
|
#endif |
|
|
|