Merge pull request #22314 from yashykt/execctxstartingcpu

Lazily initialize starting_cpu_ in ExecCtx
pull/22913/head
Yash Tibrewal 5 years ago committed by GitHub
commit 14ab949d98
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      src/core/lib/iomgr/exec_ctx.h

@ -21,6 +21,8 @@
#include <grpc/support/port_platform.h>
#include <limits>
#include <grpc/impl/codegen/grpc_types.h>
#include <grpc/support/atm.h>
#include <grpc/support/cpu.h>
@ -132,7 +134,12 @@ class ExecCtx {
ExecCtx(const ExecCtx&) = delete;
ExecCtx& operator=(const ExecCtx&) = delete;
unsigned starting_cpu() const { return starting_cpu_; }
unsigned starting_cpu() {
if (starting_cpu_ == std::numeric_limits<unsigned>::max()) {
starting_cpu_ = gpr_cpu_current_cpu();
}
return starting_cpu_;
}
struct CombinerData {
/* currently active combiner: updated only via combiner.c */
@ -239,7 +246,7 @@ class ExecCtx {
CombinerData combiner_data_ = {nullptr, nullptr};
uintptr_t flags_;
unsigned starting_cpu_ = gpr_cpu_current_cpu();
unsigned starting_cpu_ = std::numeric_limits<unsigned>::max();
bool now_is_valid_ = false;
grpc_millis now_ = 0;

Loading…
Cancel
Save