void ReportResult()

in e2e-examples/gcs/benchmark/channel_policy.cc [167:196]


  void ReportResult(void* handle, const grpc::Status& status,
                    const grpc::ClientContext& context,
                    absl::Duration elapsed_time, int64_t bytes) override {
    absl::MutexLock l(&lock_);

    // Decreases in-use count for the channel
    auto i = std::find_if(channel_states_.begin(), channel_states_.end(),
                          [handle](const ChannelState& val) {
                            return (void*)val.channel.get() == handle;
                          });
    if (i != channel_states_.end()) {
      i->in_use_count -= 1;
    }

    // If the error indicates that the channel is hopeless,
    // replace it with the newly created one.
    if (status.error_code() == grpc::StatusCode::CANCELLED ||
        status.error_code() == grpc::StatusCode::DEADLINE_EXCEEDED) {
      auto i = std::find_if(channel_states_.begin(), channel_states_.end(),
                            [handle](const ChannelState& val) {
                              return (void*)val.channel.get() == handle;
                            });
      if (i != channel_states_.end()) {
        std::cerr << "Evict the channel (peer=" << context.peer()
                  << ") due to error:" << status.error_code() << std::endl;
        i->channel = channel_creator_();
        i->in_use_count = 0;
      }
    }
  }