diff --git a/BUILD b/BUILD index 377a2eaa195f4ff90fd967a1b9f714b359f0ecc1..004f42f9582f98870d3aebc185ba7a6165a0e999 100644 --- a/BUILD +++ b/BUILD @@ -521,6 +521,7 @@ grpc_cc_library( "src/core/lib/gprpp/map.h", "src/core/lib/gprpp/memory.h", "src/core/lib/gprpp/mpscq.h", + "src/core/lib/gprpp/set.h", "src/core/lib/gprpp/string_view.h", "src/core/lib/gprpp/sync.h", "src/core/lib/gprpp/thd.h", diff --git a/BUILD.gn b/BUILD.gn index 88bf0e632e25e696f75716d439b5f4cb12518a0a..650d54c9eeed33919576fec46d9c51215d746f50 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -149,6 +149,7 @@ config("grpc_config") { "src/core/lib/gprpp/memory.h", "src/core/lib/gprpp/mpscq.cc", "src/core/lib/gprpp/mpscq.h", + "src/core/lib/gprpp/set.h", "src/core/lib/gprpp/sync.h", "src/core/lib/gprpp/thd.h", "src/core/lib/gprpp/thd_posix.cc", @@ -1253,6 +1254,7 @@ config("grpc_config") { "src/core/lib/gprpp/orphanable.h", "src/core/lib/gprpp/ref_counted.h", "src/core/lib/gprpp/ref_counted_ptr.h", + "src/core/lib/gprpp/set.h", "src/core/lib/gprpp/string_view.h", "src/core/lib/gprpp/sync.h", "src/core/lib/gprpp/thd.h", diff --git a/build.yaml b/build.yaml index b96786afbc3ce850704a07422466872ae39be67b..615ed4f793576a0583ece1d4324b4140a29980e5 100644 --- a/build.yaml +++ b/build.yaml @@ -291,6 +291,7 @@ filegroups: - src/core/lib/gprpp/map.h - src/core/lib/gprpp/memory.h - src/core/lib/gprpp/mpscq.h + - src/core/lib/gprpp/set.h - src/core/lib/gprpp/sync.h - src/core/lib/gprpp/thd.h - src/core/lib/profiling/timers.h diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 9aa8d215cc06df85c7620ea498801568cfae2d96..bf06d7bf2da08f8376582627b051240b05487f90 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -311,6 +311,7 @@ Pod::Spec.new do |s| 'src/core/lib/gprpp/map.h', 'src/core/lib/gprpp/memory.h', 'src/core/lib/gprpp/mpscq.h', + 'src/core/lib/gprpp/set.h', 'src/core/lib/gprpp/sync.h', 'src/core/lib/gprpp/thd.h', 'src/core/lib/profiling/timers.h', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index e144acb6331c010035a7a82a06c0aebfa1924c63..02718c7a40a58084ae9065905fd3388d66df8bc6 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -214,6 +214,7 @@ Pod::Spec.new do |s| 'src/core/lib/gprpp/map.h', 'src/core/lib/gprpp/memory.h', 'src/core/lib/gprpp/mpscq.h', + 'src/core/lib/gprpp/set.h', 'src/core/lib/gprpp/sync.h', 'src/core/lib/gprpp/thd.h', 'src/core/lib/profiling/timers.h', @@ -988,6 +989,7 @@ Pod::Spec.new do |s| 'src/core/lib/gprpp/map.h', 'src/core/lib/gprpp/memory.h', 'src/core/lib/gprpp/mpscq.h', + 'src/core/lib/gprpp/set.h', 'src/core/lib/gprpp/sync.h', 'src/core/lib/gprpp/thd.h', 'src/core/lib/profiling/timers.h', diff --git a/grpc.gemspec b/grpc.gemspec index ef79e0cedeaa41ccce66d192d78d4f433afc3e77..1bfd393a7c63d8689f1dee7f93fa6976c6107d77 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -108,6 +108,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/gprpp/map.h ) s.files += %w( src/core/lib/gprpp/memory.h ) s.files += %w( src/core/lib/gprpp/mpscq.h ) + s.files += %w( src/core/lib/gprpp/set.h ) s.files += %w( src/core/lib/gprpp/sync.h ) s.files += %w( src/core/lib/gprpp/thd.h ) s.files += %w( src/core/lib/profiling/timers.h ) diff --git a/package.xml b/package.xml index b9ad2970e508637deb3ba41a54df2e0af04a76cf..5a3ad6b229f27e553b20ca7926e8d2f299164be5 100644 --- a/package.xml +++ b/package.xml @@ -113,6 +113,7 @@ <file baseinstalldir="/" name="src/core/lib/gprpp/map.h" role="src" /> <file baseinstalldir="/" name="src/core/lib/gprpp/memory.h" role="src" /> <file baseinstalldir="/" name="src/core/lib/gprpp/mpscq.h" role="src" /> + <file baseinstalldir="/" name="src/core/lib/gprpp/set.h" role="src" /> <file baseinstalldir="/" name="src/core/lib/gprpp/sync.h" role="src" /> <file baseinstalldir="/" name="src/core/lib/gprpp/thd.h" role="src" /> <file baseinstalldir="/" name="src/core/lib/profiling/timers.h" role="src" /> diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc index 450bb5fd04b4ae8137d9d9d4c8c144546ad98691..12ef32ea94bce5ce3d15240c23858d4c7889fe34 100644 --- a/src/core/ext/filters/client_channel/client_channel.cc +++ b/src/core/ext/filters/client_channel/client_channel.cc @@ -26,9 +26,6 @@ #include <stdio.h> #include <string.h> -#include <map> -#include <set> - #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/string_util.h> @@ -56,6 +53,7 @@ #include "src/core/lib/gprpp/inlined_vector.h" #include "src/core/lib/gprpp/manual_constructor.h" #include "src/core/lib/gprpp/map.h" +#include "src/core/lib/gprpp/set.h" #include "src/core/lib/gprpp/sync.h" #include "src/core/lib/iomgr/combiner.h" #include "src/core/lib/iomgr/iomgr.h" @@ -297,7 +295,7 @@ class ChannelData { // The set of SubchannelWrappers that currently exist. // No need to hold a ref, since the map is updated in the control-plane // combiner when the SubchannelWrappers are created and destroyed. - std::set<SubchannelWrapper*> subchannel_wrappers_; + Set<SubchannelWrapper*> subchannel_wrappers_; // Pending ConnectedSubchannel updates for each SubchannelWrapper. // Updates are queued here in the control plane combiner and then applied // in the data plane mutex when the picker is updated. diff --git a/src/core/lib/gprpp/memory.h b/src/core/lib/gprpp/memory.h index 53b89507c6febb818e38a67b310dedffad06506d..26917ef1c8490b484497801efe7c2da71e1e596d 100644 --- a/src/core/lib/gprpp/memory.h +++ b/src/core/lib/gprpp/memory.h @@ -103,6 +103,11 @@ class Allocator { }; typedef std::true_type is_always_equal; + Allocator() = default; + + template <class U> + Allocator(const Allocator<U>&) {} + pointer address(reference x) const { return &x; } const_pointer address(const_reference x) const { return &x; } pointer allocate(std::size_t n, diff --git a/src/core/lib/gprpp/set.h b/src/core/lib/gprpp/set.h new file mode 100644 index 0000000000000000000000000000000000000000..89535929c3c612bf4847d9c9ed5aaad90a136ce0 --- /dev/null +++ b/src/core/lib/gprpp/set.h @@ -0,0 +1,33 @@ +// +// Copyright 2017 gRPC authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#ifndef GRPC_CORE_LIB_GPRPP_SET_H +#define GRPC_CORE_LIB_GPRPP_SET_H + +#include <grpc/support/port_platform.h> + +#include <set> + +#include "src/core/lib/gprpp/memory.h" + +namespace grpc_core { + +template <typename T, typename Compare = std::less<T>> +using Set = std::set<T, Compare, Allocator<T>>; + +} // namespace grpc_core + +#endif /* GRPC_CORE_LIB_GPRPP_SET_H */ diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index ada328dd92fa1046dcc2c13e814f9c45544903f9..28042e17ba11f4e27325d5dcf663ecd94aba6c2e 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -1119,6 +1119,7 @@ src/core/lib/gprpp/optional.h \ src/core/lib/gprpp/orphanable.h \ src/core/lib/gprpp/ref_counted.h \ src/core/lib/gprpp/ref_counted_ptr.h \ +src/core/lib/gprpp/set.h \ src/core/lib/gprpp/string_view.h \ src/core/lib/gprpp/sync.h \ src/core/lib/gprpp/thd.h \ diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index bc199120f0008a60a4f02a6ac78abf052cea1bd4..9898945bddc24bad00d5aa028b7e5d08ab016655 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -1255,6 +1255,7 @@ src/core/lib/gprpp/optional.h \ src/core/lib/gprpp/orphanable.h \ src/core/lib/gprpp/ref_counted.h \ src/core/lib/gprpp/ref_counted_ptr.h \ +src/core/lib/gprpp/set.h \ src/core/lib/gprpp/string_view.h \ src/core/lib/gprpp/sync.h \ src/core/lib/gprpp/thd.h \