diff options
Diffstat (limited to 'grpc/src/core/ext/filters/client_channel/global_subchannel_pool.h')
-rw-r--r-- | grpc/src/core/ext/filters/client_channel/global_subchannel_pool.h | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/grpc/src/core/ext/filters/client_channel/global_subchannel_pool.h b/grpc/src/core/ext/filters/client_channel/global_subchannel_pool.h index 96dc8d7b..7ff9b070 100644 --- a/grpc/src/core/ext/filters/client_channel/global_subchannel_pool.h +++ b/grpc/src/core/ext/filters/client_channel/global_subchannel_pool.h @@ -21,7 +21,10 @@ #include <grpc/support/port_platform.h> +#include <map> + #include "src/core/ext/filters/client_channel/subchannel_pool_interface.h" +#include "src/core/lib/gprpp/sync.h" namespace grpc_core { @@ -33,8 +36,8 @@ namespace grpc_core { class GlobalSubchannelPool final : public SubchannelPoolInterface { public: // The ctor and dtor are not intended to use directly. - GlobalSubchannelPool(); - ~GlobalSubchannelPool() override; + GlobalSubchannelPool() {} + ~GlobalSubchannelPool() override {} // Should be called exactly once at filter initialization time. static void Init(); @@ -45,22 +48,24 @@ class GlobalSubchannelPool final : public SubchannelPoolInterface { static RefCountedPtr<GlobalSubchannelPool> instance(); // Implements interface methods. - Subchannel* RegisterSubchannel(SubchannelKey* key, - Subchannel* constructed) override; - void UnregisterSubchannel(SubchannelKey* key) override; - Subchannel* FindSubchannel(SubchannelKey* key) override; + RefCountedPtr<Subchannel> RegisterSubchannel( + const SubchannelKey& key, RefCountedPtr<Subchannel> constructed) override + ABSL_LOCKS_EXCLUDED(mu_); + void UnregisterSubchannel(const SubchannelKey& key, + Subchannel* subchannel) override + ABSL_LOCKS_EXCLUDED(mu_); + RefCountedPtr<Subchannel> FindSubchannel(const SubchannelKey& key) override + ABSL_LOCKS_EXCLUDED(mu_); private: // The singleton instance. (It's a pointer to RefCountedPtr so that this // non-local static object can be trivially destructible.) static RefCountedPtr<GlobalSubchannelPool>* instance_; - // The vtable for subchannel operations in an AVL tree. - static const grpc_avl_vtable subchannel_avl_vtable_; // A map from subchannel key to subchannel. - grpc_avl subchannel_map_; + std::map<SubchannelKey, Subchannel*> subchannel_map_ ABSL_GUARDED_BY(mu_); // To protect subchannel_map_. - gpr_mu mu_; + Mutex mu_; }; } // namespace grpc_core |