From 444f548312e31b6cbff76c1c22bfdad2a95c5a6d Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 29 May 2024 11:21:57 -0700 Subject: [PATCH] x --- src/core/client_channel/client_channel.cc | 62 ++++++++++++----------- src/core/client_channel/client_channel.h | 13 +---- 2 files changed, 35 insertions(+), 40 deletions(-) diff --git a/src/core/client_channel/client_channel.cc b/src/core/client_channel/client_channel.cc index ec53ecbd117..77de1ab121d 100644 --- a/src/core/client_channel/client_channel.cc +++ b/src/core/client_channel/client_channel.cc @@ -123,10 +123,43 @@ extern TraceFlag grpc_client_channel_trace; extern TraceFlag grpc_client_channel_call_trace; extern TraceFlag grpc_client_channel_lb_call_trace; +// +// ClientChannel::ResolverResultHandler +// + +class ClientChannel::ResolverResultHandler : public Resolver::ResultHandler { + public: + explicit ResolverResultHandler(RefCountedPtr client_channel) + : client_channel_(std::move(client_channel)) {} + + ~ResolverResultHandler() override { + if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_trace)) { + gpr_log(GPR_INFO, "client_channel=%p: resolver shutdown complete", + client_channel_.get()); + } + } + + void ReportResult(Resolver::Result result) override + ABSL_EXCLUSIVE_LOCKS_REQUIRED(*client_channel_->work_serializer_) { + client_channel_->OnResolverResultChangedLocked(std::move(result)); + } + + private: + RefCountedPtr client_channel_; +}; + // // ClientChannel::SubchannelWrapper // +// This class is a wrapper for Subchannel that hides details of the +// channel's implementation (such as the connected subchannel) from the +// LB policy API. +// +// Note that no synchronization is needed here, because even if the +// underlying subchannel is shared between channels, this wrapper will only +// be used within one channel, so it will always be synchronized by the +// control plane work_serializer. class ClientChannel::SubchannelWrapper : public SubchannelInterfaceWithCallDestination { public: @@ -190,35 +223,6 @@ class ClientChannel::SubchannelWrapper data_watchers_ ABSL_GUARDED_BY(*client_channel_->work_serializer_); }; -// -// ClientChannel::ResolverResultHandler -// - -class ClientChannel::ResolverResultHandler : public Resolver::ResultHandler { - public: - explicit ResolverResultHandler(RefCountedPtr client_channel) - : client_channel_(std::move(client_channel)) {} - - ~ResolverResultHandler() override { - if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_trace)) { - gpr_log(GPR_INFO, "client_channel=%p: resolver shutdown complete", - client_channel_.get()); - } - } - - void ReportResult(Resolver::Result result) override - ABSL_EXCLUSIVE_LOCKS_REQUIRED(*client_channel_->work_serializer_) { - client_channel_->OnResolverResultChangedLocked(std::move(result)); - } - - private: - RefCountedPtr client_channel_; -}; - -// -// ClientChannel::SubchannelWrapper -// - // This wrapper provides a bridge between the internal Subchannel API // and the SubchannelInterface API that we expose to LB policies. // It implements Subchannel::ConnectivityStateWatcherInterface and wraps diff --git a/src/core/client_channel/client_channel.h b/src/core/client_channel/client_channel.h index c8c3b564d4f..77d26f34e95 100644 --- a/src/core/client_channel/client_channel.h +++ b/src/core/client_channel/client_channel.h @@ -39,16 +39,6 @@ namespace grpc_core { class ClientChannel : public Channel { public: - // This class is a wrapper for Subchannel that hides details of the - // channel's implementation (such as the connected subchannel) from the - // LB policy API. - // - // Note that no synchronization is needed here, because even if the - // underlying subchannel is shared between channels, this wrapper will only - // be used within one channel, so it will always be synchronized by the - // control plane work_serializer. - class SubchannelWrapper; - using PickerObservable = Observable>; @@ -132,8 +122,9 @@ class ClientChannel : public Channel { } private: - class ResolverResultHandler; class ClientChannelControlHelper; + class ResolverResultHandler; + class SubchannelWrapper; void CreateResolverLocked() ABSL_EXCLUSIVE_LOCKS_REQUIRED(*work_serializer_); void DestroyResolverAndLbPolicyLocked()