|
|
@ -29,20 +29,9 @@ |
|
|
|
namespace grpc_core { |
|
|
|
namespace grpc_core { |
|
|
|
|
|
|
|
|
|
|
|
// The global subchannel pool. It shares subchannels among channels. There
|
|
|
|
// The global subchannel pool. It shares subchannels among channels. There
|
|
|
|
// should be only one instance of this class. Init() should be called once at
|
|
|
|
// should be only one instance of this class.
|
|
|
|
// the filter initialization time; Shutdown() should be called once at the
|
|
|
|
|
|
|
|
// filter shutdown time.
|
|
|
|
|
|
|
|
class GlobalSubchannelPool final : public SubchannelPoolInterface { |
|
|
|
class GlobalSubchannelPool final : public SubchannelPoolInterface { |
|
|
|
public: |
|
|
|
public: |
|
|
|
// The ctor and dtor are not intended to use directly.
|
|
|
|
|
|
|
|
GlobalSubchannelPool() {} |
|
|
|
|
|
|
|
~GlobalSubchannelPool() override {} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Should be called exactly once at filter initialization time.
|
|
|
|
|
|
|
|
static void Init(); |
|
|
|
|
|
|
|
// Should be called exactly once at filter shutdown time.
|
|
|
|
|
|
|
|
static void Shutdown(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Gets the singleton instance.
|
|
|
|
// Gets the singleton instance.
|
|
|
|
static RefCountedPtr<GlobalSubchannelPool> instance(); |
|
|
|
static RefCountedPtr<GlobalSubchannelPool> instance(); |
|
|
|
|
|
|
|
|
|
|
@ -57,9 +46,8 @@ class GlobalSubchannelPool final : public SubchannelPoolInterface { |
|
|
|
ABSL_LOCKS_EXCLUDED(mu_); |
|
|
|
ABSL_LOCKS_EXCLUDED(mu_); |
|
|
|
|
|
|
|
|
|
|
|
private: |
|
|
|
private: |
|
|
|
// The singleton instance. (It's a pointer to RefCountedPtr so that this
|
|
|
|
GlobalSubchannelPool() {} |
|
|
|
// non-local static object can be trivially destructible.)
|
|
|
|
~GlobalSubchannelPool() override {} |
|
|
|
static RefCountedPtr<GlobalSubchannelPool>* instance_; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// A map from subchannel key to subchannel.
|
|
|
|
// A map from subchannel key to subchannel.
|
|
|
|
std::map<SubchannelKey, Subchannel*> subchannel_map_ ABSL_GUARDED_BY(mu_); |
|
|
|
std::map<SubchannelKey, Subchannel*> subchannel_map_ ABSL_GUARDED_BY(mu_); |
|
|
|