diff --git a/BUILD b/BUILD index 12313bcfa34..1128f715c79 100644 --- a/BUILD +++ b/BUILD @@ -69,11 +69,6 @@ config_setting( values = {"cpu": "darwin"}, ) -config_setting( - name = "grpc_use_cpp_std_lib", - values = {"define": "GRPC_USE_CPP_STD_LIB=1"}, -) - python_config_settings() # This should be updated along with build.yaml @@ -514,7 +509,6 @@ grpc_cc_library( "src/core/lib/gpr/tls_pthread.h", "src/core/lib/gpr/tmpfile.h", "src/core/lib/gpr/useful.h", - "src/core/lib/gprpp/abstract.h", "src/core/lib/gprpp/arena.h", "src/core/lib/gprpp/atomic.h", "src/core/lib/gprpp/fork.h", diff --git a/BUILD.gn b/BUILD.gn index 7ad8f248bdf..0e3e5c51c7b 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -132,7 +132,6 @@ config("grpc_config") { "src/core/lib/gpr/tmpfile_windows.cc", "src/core/lib/gpr/useful.h", "src/core/lib/gpr/wrap_memcpy.cc", - "src/core/lib/gprpp/abstract.h", "src/core/lib/gprpp/arena.cc", "src/core/lib/gprpp/arena.h", "src/core/lib/gprpp/atomic.h", @@ -1237,7 +1236,6 @@ config("grpc_config") { "src/core/lib/gpr/tls_pthread.h", "src/core/lib/gpr/tmpfile.h", "src/core/lib/gpr/useful.h", - "src/core/lib/gprpp/abstract.h", "src/core/lib/gprpp/arena.h", "src/core/lib/gprpp/atomic.h", "src/core/lib/gprpp/debug_location.h", diff --git a/CMakeLists.txt b/CMakeLists.txt index 518ca81c664..59c575f894c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -631,7 +631,6 @@ add_dependencies(buildtests_cxx golden_file_test) add_dependencies(buildtests_cxx gprpp_mpscq_test) add_dependencies(buildtests_cxx grpc_alts_credentials_options_test) add_dependencies(buildtests_cxx grpc_cli) -add_dependencies(buildtests_cxx grpc_core_map_test) add_dependencies(buildtests_cxx grpc_fetch_oauth2) add_dependencies(buildtests_cxx grpc_linux_system_roots_test) add_dependencies(buildtests_cxx grpc_spiffe_security_connector_test) @@ -13408,47 +13407,6 @@ target_link_libraries(grpc_cli ) -endif (gRPC_BUILD_TESTS) -if (gRPC_BUILD_TESTS) - -add_executable(grpc_core_map_test - test/core/gprpp/map_test.cc - third_party/googletest/googletest/src/gtest-all.cc - third_party/googletest/googlemock/src/gmock-all.cc -) - - -target_include_directories(grpc_core_map_test - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} - PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR} - PRIVATE ${_gRPC_CARES_INCLUDE_DIR} - PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR} - PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR} - PRIVATE ${_gRPC_SSL_INCLUDE_DIR} - PRIVATE ${_gRPC_UPB_GENERATED_DIR} - PRIVATE ${_gRPC_UPB_GRPC_GENERATED_DIR} - PRIVATE ${_gRPC_UPB_INCLUDE_DIR} - PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR} - PRIVATE third_party/googletest/googletest/include - PRIVATE third_party/googletest/googletest - PRIVATE third_party/googletest/googlemock/include - PRIVATE third_party/googletest/googlemock - PRIVATE ${_gRPC_PROTO_GENS_DIR} -) - -target_link_libraries(grpc_core_map_test - ${_gRPC_PROTOBUF_LIBRARIES} - ${_gRPC_ALLTARGETS_LIBRARIES} - grpc_test_util - grpc++ - grpc - gpr - ${_gRPC_GFLAGS_LIBRARIES} -) - - endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_CODEGEN) diff --git a/Makefile b/Makefile index 20e01d6c10c..9358cc3205d 100644 --- a/Makefile +++ b/Makefile @@ -1220,7 +1220,6 @@ golden_file_test: $(BINDIR)/$(CONFIG)/golden_file_test gprpp_mpscq_test: $(BINDIR)/$(CONFIG)/gprpp_mpscq_test grpc_alts_credentials_options_test: $(BINDIR)/$(CONFIG)/grpc_alts_credentials_options_test grpc_cli: $(BINDIR)/$(CONFIG)/grpc_cli -grpc_core_map_test: $(BINDIR)/$(CONFIG)/grpc_core_map_test grpc_cpp_plugin: $(BINDIR)/$(CONFIG)/grpc_cpp_plugin grpc_csharp_plugin: $(BINDIR)/$(CONFIG)/grpc_csharp_plugin grpc_fetch_oauth2: $(BINDIR)/$(CONFIG)/grpc_fetch_oauth2 @@ -1699,7 +1698,6 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/gprpp_mpscq_test \ $(BINDIR)/$(CONFIG)/grpc_alts_credentials_options_test \ $(BINDIR)/$(CONFIG)/grpc_cli \ - $(BINDIR)/$(CONFIG)/grpc_core_map_test \ $(BINDIR)/$(CONFIG)/grpc_fetch_oauth2 \ $(BINDIR)/$(CONFIG)/grpc_linux_system_roots_test \ $(BINDIR)/$(CONFIG)/grpc_spiffe_security_connector_test \ @@ -1870,7 +1868,6 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/gprpp_mpscq_test \ $(BINDIR)/$(CONFIG)/grpc_alts_credentials_options_test \ $(BINDIR)/$(CONFIG)/grpc_cli \ - $(BINDIR)/$(CONFIG)/grpc_core_map_test \ $(BINDIR)/$(CONFIG)/grpc_fetch_oauth2 \ $(BINDIR)/$(CONFIG)/grpc_linux_system_roots_test \ $(BINDIR)/$(CONFIG)/grpc_spiffe_security_connector_test \ @@ -2378,8 +2375,6 @@ test_cxx: buildtests_cxx $(Q) $(BINDIR)/$(CONFIG)/gprpp_mpscq_test || ( echo test gprpp_mpscq_test failed ; exit 1 ) $(E) "[RUN] Testing grpc_alts_credentials_options_test" $(Q) $(BINDIR)/$(CONFIG)/grpc_alts_credentials_options_test || ( echo test grpc_alts_credentials_options_test failed ; exit 1 ) - $(E) "[RUN] Testing grpc_core_map_test" - $(Q) $(BINDIR)/$(CONFIG)/grpc_core_map_test || ( echo test grpc_core_map_test failed ; exit 1 ) $(E) "[RUN] Testing grpc_linux_system_roots_test" $(Q) $(BINDIR)/$(CONFIG)/grpc_linux_system_roots_test || ( echo test grpc_linux_system_roots_test failed ; exit 1 ) $(E) "[RUN] Testing grpc_spiffe_security_connector_test" @@ -16803,49 +16798,6 @@ endif endif -GRPC_CORE_MAP_TEST_SRC = \ - test/core/gprpp/map_test.cc \ - -GRPC_CORE_MAP_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GRPC_CORE_MAP_TEST_SRC)))) -ifeq ($(NO_SECURE),true) - -# You can't build secure targets if you don't have OpenSSL. - -$(BINDIR)/$(CONFIG)/grpc_core_map_test: openssl_dep_error - -else - - - - -ifeq ($(NO_PROTOBUF),true) - -# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.5.0+. - -$(BINDIR)/$(CONFIG)/grpc_core_map_test: protobuf_dep_error - -else - -$(BINDIR)/$(CONFIG)/grpc_core_map_test: $(PROTOBUF_DEP) $(GRPC_CORE_MAP_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a - $(E) "[LD] Linking $@" - $(Q) mkdir -p `dirname $@` - $(Q) $(LDXX) $(LDFLAGS) $(GRPC_CORE_MAP_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/grpc_core_map_test - -endif - -endif - -$(OBJDIR)/$(CONFIG)/test/core/gprpp/map_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a - -deps_grpc_core_map_test: $(GRPC_CORE_MAP_TEST_OBJS:.o=.dep) - -ifneq ($(NO_SECURE),true) -ifneq ($(NO_DEPS),true) --include $(GRPC_CORE_MAP_TEST_OBJS:.o=.dep) -endif -endif - - GRPC_CPP_PLUGIN_SRC = \ src/compiler/cpp_plugin.cc \ diff --git a/bazel/grpc_build_system.bzl b/bazel/grpc_build_system.bzl index ed137285334..95c639c9dbc 100644 --- a/bazel/grpc_build_system.bzl +++ b/bazel/grpc_build_system.bzl @@ -98,9 +98,6 @@ def grpc_cc_library( "//:grpc_allow_exceptions": ["GRPC_ALLOW_EXCEPTIONS=1"], "//:grpc_disallow_exceptions": ["GRPC_ALLOW_EXCEPTIONS=0"], "//conditions:default": [], - }) + select({ - "//:grpc_use_cpp_std_lib": ["GRPC_USE_CPP_STD_LIB=1"], - "//conditions:default": [], }), hdrs = hdrs + public_hdrs, deps = deps + _get_external_deps(external_deps), diff --git a/build.yaml b/build.yaml index 81058a6d1c9..285a33a0140 100644 --- a/build.yaml +++ b/build.yaml @@ -279,7 +279,6 @@ filegroups: - src/core/lib/gpr/tls_pthread.h - src/core/lib/gpr/tmpfile.h - src/core/lib/gpr/useful.h - - src/core/lib/gprpp/abstract.h - src/core/lib/gprpp/arena.h - src/core/lib/gprpp/atomic.h - src/core/lib/gprpp/fork.h @@ -5016,20 +5015,6 @@ targets: - grpc - gpr - grpc++_test_config -- name: grpc_core_map_test - gtest: true - build: test - language: c++ - headers: - - test/core/gprpp/map_tester.h - src: - - test/core/gprpp/map_test.cc - deps: - - grpc_test_util - - grpc++ - - grpc - - gpr - uses_polling: false - name: grpc_cpp_plugin build: protoc language: c++ diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 87de0d91a81..bc844cd4517 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -299,7 +299,6 @@ Pod::Spec.new do |s| 'src/core/lib/gpr/tls_pthread.h', 'src/core/lib/gpr/tmpfile.h', 'src/core/lib/gpr/useful.h', - 'src/core/lib/gprpp/abstract.h', 'src/core/lib/gprpp/arena.h', 'src/core/lib/gprpp/atomic.h', 'src/core/lib/gprpp/fork.h', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index da18f800006..8be7a3d7e5d 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -202,7 +202,6 @@ Pod::Spec.new do |s| 'src/core/lib/gpr/tls_pthread.h', 'src/core/lib/gpr/tmpfile.h', 'src/core/lib/gpr/useful.h', - 'src/core/lib/gprpp/abstract.h', 'src/core/lib/gprpp/arena.h', 'src/core/lib/gprpp/atomic.h', 'src/core/lib/gprpp/fork.h', @@ -978,7 +977,6 @@ Pod::Spec.new do |s| 'src/core/lib/gpr/tls_pthread.h', 'src/core/lib/gpr/tmpfile.h', 'src/core/lib/gpr/useful.h', - 'src/core/lib/gprpp/abstract.h', 'src/core/lib/gprpp/arena.h', 'src/core/lib/gprpp/atomic.h', 'src/core/lib/gprpp/fork.h', diff --git a/grpc.gemspec b/grpc.gemspec index baa52fb9830..698d9f162b5 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -96,7 +96,6 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/gpr/tls_pthread.h ) s.files += %w( src/core/lib/gpr/tmpfile.h ) s.files += %w( src/core/lib/gpr/useful.h ) - s.files += %w( src/core/lib/gprpp/abstract.h ) s.files += %w( src/core/lib/gprpp/arena.h ) s.files += %w( src/core/lib/gprpp/atomic.h ) s.files += %w( src/core/lib/gprpp/fork.h ) diff --git a/include/grpc/impl/codegen/port_platform.h b/include/grpc/impl/codegen/port_platform.h index d1767ab0b75..fe414023dac 100644 --- a/include/grpc/impl/codegen/port_platform.h +++ b/include/grpc/impl/codegen/port_platform.h @@ -27,14 +27,6 @@ * - some syscalls to be made directly */ -/* - * Defines GRPC_USE_CPP_STD_LIB to use standard C++ library instead of - * in-house library if possible. (e.g. std::map) - */ -#ifndef GRPC_USE_CPP_STD_LIB -#define GRPC_USE_CPP_STD_LIB 1 -#endif - /* Get windows.h included everywhere (we need it) */ #if defined(_WIN64) || defined(WIN64) || defined(_WIN32) || defined(WIN32) #ifndef WIN32_LEAN_AND_MEAN diff --git a/package.xml b/package.xml index d8633ebfde1..56807a958c7 100644 --- a/package.xml +++ b/package.xml @@ -101,7 +101,6 @@ - diff --git a/src/core/ext/filters/client_channel/backend_metric.cc b/src/core/ext/filters/client_channel/backend_metric.cc index 0d6aa2f6e2c..b36614f5b80 100644 --- a/src/core/ext/filters/client_channel/backend_metric.cc +++ b/src/core/ext/filters/client_channel/backend_metric.cc @@ -26,12 +26,12 @@ namespace grpc_core { namespace { template -Map ParseMap( +std::map ParseMap( udpa_data_orca_v1_OrcaLoadReport* msg, EntryType** (*entry_func)(udpa_data_orca_v1_OrcaLoadReport*, size_t*), upb_strview (*key_func)(const EntryType*), double (*value_func)(const EntryType*), Arena* arena) { - Map result; + std::map result; size_t size; const auto* const* entries = entry_func(msg, &size); for (size_t i = 0; i < size; ++i) { diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc index af2425a6faa..70746f4783f 100644 --- a/src/core/ext/filters/client_channel/client_channel.cc +++ b/src/core/ext/filters/client_channel/client_channel.cc @@ -282,18 +282,18 @@ class ChannelData { RefCountedPtr saved_service_config_; bool received_first_resolver_result_ = false; // The number of SubchannelWrapper instances referencing a given Subchannel. - Map subchannel_refcount_map_; + std::map subchannel_refcount_map_; // 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. // TODO(roth): We really want to use a set here, not a map. Since we don't // currently have a set implementation, we use a map and ignore the value. - Map subchannel_wrappers_; + std::map 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. - Map, RefCountedPtr, - RefCountedPtrLess> + std::map, RefCountedPtr, + RefCountedPtrLess> pending_subchannel_updates_; // @@ -314,7 +314,7 @@ class ChannelData { // synchronously via grpc_channel_num_external_connectivity_watchers(). // mutable Mutex external_watchers_mu_; - Map external_watchers_; + std::map external_watchers_; }; // @@ -1107,7 +1107,7 @@ class ChannelData::SubchannelWrapper : public SubchannelInterface { // subchannel. This is needed so that when the LB policy calls // CancelConnectivityStateWatch() with its watcher, we know the // corresponding WrapperWatcher to cancel on the underlying subchannel. - Map watcher_map_; + std::map watcher_map_; // To be accessed only in the control plane combiner. RefCountedPtr connected_subchannel_; // To be accessed only in the data plane mutex. diff --git a/src/core/ext/filters/client_channel/client_channel_factory.h b/src/core/ext/filters/client_channel/client_channel_factory.h index 42bc7cb505f..79797bbc454 100644 --- a/src/core/ext/filters/client_channel/client_channel_factory.h +++ b/src/core/ext/filters/client_channel/client_channel_factory.h @@ -24,7 +24,6 @@ #include #include "src/core/ext/filters/client_channel/subchannel.h" -#include "src/core/lib/gprpp/abstract.h" namespace grpc_core { @@ -33,8 +32,7 @@ class ClientChannelFactory { virtual ~ClientChannelFactory() = default; // Creates a subchannel with the specified args. - virtual Subchannel* CreateSubchannel(const grpc_channel_args* args) - GRPC_ABSTRACT; + virtual Subchannel* CreateSubchannel(const grpc_channel_args* args) = 0; // Returns a channel arg containing the specified factory. static grpc_arg CreateChannelArg(ClientChannelFactory* factory); @@ -42,8 +40,6 @@ class ClientChannelFactory { // Returns the factory from args, or null if not found. static ClientChannelFactory* GetFromChannelArgs( const grpc_channel_args* args); - - GRPC_ABSTRACT_BASE_CLASS }; } // namespace grpc_core diff --git a/src/core/ext/filters/client_channel/lb_policy.h b/src/core/ext/filters/client_channel/lb_policy.h index 093d5fc30b8..20957c3daaf 100644 --- a/src/core/ext/filters/client_channel/lb_policy.h +++ b/src/core/ext/filters/client_channel/lb_policy.h @@ -24,7 +24,6 @@ #include "src/core/ext/filters/client_channel/server_address.h" #include "src/core/ext/filters/client_channel/service_config.h" #include "src/core/ext/filters/client_channel/subchannel_interface.h" -#include "src/core/lib/gprpp/abstract.h" #include "src/core/lib/gprpp/map.h" #include "src/core/lib/gprpp/orphanable.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" @@ -91,11 +90,11 @@ class LoadBalancingPolicy : public InternallyRefCounted { /// Application-specific requests cost metrics. Metric names are /// determined by the application. Each value is an absolute cost /// (e.g. 3487 bytes of storage) associated with the request. - Map request_cost; + std::map request_cost; /// Application-specific resource utilization metrics. Metric names /// are determined by the application. Each value is expressed as a /// fraction of total resources available. - Map utilization; + std::map utilization; }; /// Interface for accessing per-call state. @@ -109,13 +108,11 @@ class LoadBalancingPolicy : public InternallyRefCounted { /// automatically freed when the call is complete. /// It is more efficient to use this than to allocate memory directly /// for allocations that need to be made on a per-call basis. - virtual void* Alloc(size_t size) GRPC_ABSTRACT; + virtual void* Alloc(size_t size) = 0; /// Returns the backend metric data returned by the server for the call, /// or null if no backend metric data was returned. - virtual const BackendMetricData* GetBackendMetricData() GRPC_ABSTRACT; - - GRPC_ABSTRACT_BASE_CLASS + virtual const BackendMetricData* GetBackendMetricData() = 0; }; /// Interface for accessing metadata. @@ -134,20 +131,18 @@ class LoadBalancingPolicy : public InternallyRefCounted { /// Implementations must ensure that the key and value remain alive /// until the call ends. If desired, they may be allocated via /// CallState::Alloc(). - virtual void Add(StringView key, StringView value) GRPC_ABSTRACT; + virtual void Add(StringView key, StringView value) = 0; /// Iteration interface. - virtual Iterator Begin() const GRPC_ABSTRACT; - virtual bool IsEnd(Iterator it) const GRPC_ABSTRACT; - virtual void Next(Iterator* it) const GRPC_ABSTRACT; - virtual StringView Key(Iterator it) const GRPC_ABSTRACT; - virtual StringView Value(Iterator it) const GRPC_ABSTRACT; + virtual Iterator Begin() const = 0; + virtual bool IsEnd(Iterator it) const = 0; + virtual void Next(Iterator* it) const = 0; + virtual StringView Key(Iterator it) const = 0; + virtual StringView Value(Iterator it) const = 0; /// Removes the element pointed to by \a it, which is modified to /// point to the next element. - virtual void Erase(Iterator* it) GRPC_ABSTRACT; - - GRPC_ABSTRACT_BASE_CLASS + virtual void Erase(Iterator* it) = 0; }; /// Arguments used when picking a subchannel for a call. @@ -229,9 +224,7 @@ class LoadBalancingPolicy : public InternallyRefCounted { SubchannelPicker() = default; virtual ~SubchannelPicker() = default; - virtual PickResult Pick(PickArgs args) GRPC_ABSTRACT; - - GRPC_ABSTRACT_BASE_CLASS + virtual PickResult Pick(PickArgs args) = 0; }; /// A proxy object implemented by the client channel and used by the @@ -246,22 +239,19 @@ class LoadBalancingPolicy : public InternallyRefCounted { /// Creates a new subchannel with the specified channel args. virtual RefCountedPtr CreateSubchannel( - const grpc_channel_args& args) GRPC_ABSTRACT; + const grpc_channel_args& args) = 0; /// Sets the connectivity state and returns a new picker to be used /// by the client channel. virtual void UpdateState(grpc_connectivity_state state, - UniquePtr) GRPC_ABSTRACT; + UniquePtr) = 0; /// Requests that the resolver re-resolve. - virtual void RequestReresolution() GRPC_ABSTRACT; + virtual void RequestReresolution() = 0; /// Adds a trace message associated with the channel. enum TraceSeverity { TRACE_INFO, TRACE_WARNING, TRACE_ERROR }; - virtual void AddTraceEvent(TraceSeverity severity, - StringView message) GRPC_ABSTRACT; - - GRPC_ABSTRACT_BASE_CLASS + virtual void AddTraceEvent(TraceSeverity severity, StringView message) = 0; }; /// Interface for configuration data used by an LB policy implementation. @@ -272,9 +262,7 @@ class LoadBalancingPolicy : public InternallyRefCounted { virtual ~Config() = default; // Returns the load balancing policy name - virtual const char* name() const GRPC_ABSTRACT; - - GRPC_ABSTRACT_BASE_CLASS + virtual const char* name() const = 0; }; /// Data passed to the UpdateLocked() method when new addresses and @@ -319,12 +307,12 @@ class LoadBalancingPolicy : public InternallyRefCounted { LoadBalancingPolicy& operator=(const LoadBalancingPolicy&) = delete; /// Returns the name of the LB policy. - virtual const char* name() const GRPC_ABSTRACT; + virtual const char* name() const = 0; /// Updates the policy with new data from the resolver. Will be invoked /// immediately after LB policy is constructed, and then again whenever /// the resolver returns a new result. - virtual void UpdateLocked(UpdateArgs) GRPC_ABSTRACT; // NOLINT + virtual void UpdateLocked(UpdateArgs) = 0; // NOLINT /// Tries to enter a READY connectivity state. /// This is a no-op by default, since most LB policies never go into @@ -332,7 +320,7 @@ class LoadBalancingPolicy : public InternallyRefCounted { virtual void ExitIdleLocked() {} /// Resets connection backoff. - virtual void ResetBackoffLocked() GRPC_ABSTRACT; + virtual void ResetBackoffLocked() = 0; grpc_pollset_set* interested_parties() const { return interested_parties_; } @@ -370,8 +358,6 @@ class LoadBalancingPolicy : public InternallyRefCounted { grpc_error* error_; }; - GRPC_ABSTRACT_BASE_CLASS - protected: grpc_combiner* combiner() const { return combiner_; } @@ -382,7 +368,7 @@ class LoadBalancingPolicy : public InternallyRefCounted { } /// Shuts down the policy. - virtual void ShutdownLocked() GRPC_ABSTRACT; + virtual void ShutdownLocked() = 0; private: /// Combiner under which LB policy actions take place. diff --git a/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h b/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h index b4d3fab91be..5354af7acd4 100644 --- a/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +++ b/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h @@ -33,7 +33,6 @@ #include "src/core/ext/filters/client_channel/subchannel_interface.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/debug/trace.h" -#include "src/core/lib/gprpp/abstract.h" #include "src/core/lib/gprpp/inlined_vector.h" #include "src/core/lib/gprpp/orphanable.h" #include "src/core/lib/gprpp/ref_counted.h" @@ -117,8 +116,6 @@ class SubchannelData { // Cancels any pending connectivity watch and unrefs the subchannel. void ShutdownLocked(); - GRPC_ABSTRACT_BASE_CLASS - protected: SubchannelData( SubchannelList* subchannel_list, @@ -131,7 +128,7 @@ class SubchannelData { // invoked whenever the subchannel's connectivity state changes. // To stop watching, use CancelConnectivityWatchLocked(). virtual void ProcessConnectivityChangeLocked( - grpc_connectivity_state connectivity_state) GRPC_ABSTRACT; + grpc_connectivity_state connectivity_state) = 0; private: // Watcher for subchannel connectivity state. @@ -200,8 +197,6 @@ class SubchannelList : public InternallyRefCounted { InternallyRefCounted::Unref(DEBUG_LOCATION, "shutdown"); } - GRPC_ABSTRACT_BASE_CLASS - protected: SubchannelList(LoadBalancingPolicy* policy, TraceFlag* tracer, const ServerAddressList& addresses, diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc b/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc index c148023bf5b..e0fa6c31dcd 100644 --- a/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +++ b/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc @@ -576,8 +576,8 @@ class XdsLb : public LoadBalancingPolicy { RefCountedPtr xds_policy_; - Map, OrphanablePtr, - XdsLocalityName::Less> + std::map, OrphanablePtr, + XdsLocalityName::Less> localities_; const uint32_t priority_; grpc_connectivity_state connectivity_state_ = GRPC_CHANNEL_IDLE; diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.cc b/src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.cc index a866d50b3a6..f2f06b467f2 100644 --- a/src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.cc +++ b/src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.cc @@ -143,15 +143,11 @@ XdsClientStats::Snapshot XdsClientStats::GetSnapshotAndReset() { } { MutexLock lock(&dropped_requests_mu_); -#if GRPC_USE_CPP_STD_LIB // This is a workaround for the case where some compilers cannot build // move-assignment of map with non-copyable but movable key. // https://stackoverflow.com/questions/36475497 std::swap(snapshot.dropped_requests, dropped_requests_); dropped_requests_.clear(); -#else - snapshot.dropped_requests = std::move(dropped_requests_); -#endif } return snapshot; } diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.h b/src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.h index 6e8dd961ea9..8a8af4426b4 100644 --- a/src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.h +++ b/src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.h @@ -111,9 +111,9 @@ class XdsClientStats { double total_metric_value_{0}; }; - using LoadMetricMap = Map, LoadMetric, StringLess>; + using LoadMetricMap = std::map, LoadMetric, StringLess>; using LoadMetricSnapshotMap = - Map, LoadMetric::Snapshot, StringLess>; + std::map, LoadMetric::Snapshot, StringLess>; struct Snapshot { // TODO(juanlishen): Change this to const method when const_iterator is @@ -180,12 +180,12 @@ class XdsClientStats { // UniquePtr<>. We should remove this wrapper if the value type of Map<> // doesn't have to be movable. using LocalityStatsMap = - Map, RefCountedPtr, - XdsLocalityName::Less>; + std::map, RefCountedPtr, + XdsLocalityName::Less>; using LocalityStatsSnapshotMap = - Map, LocalityStats::Snapshot, - XdsLocalityName::Less>; - using DroppedRequestsMap = Map, uint64_t, StringLess>; + std::map, LocalityStats::Snapshot, + XdsLocalityName::Less>; + using DroppedRequestsMap = std::map, uint64_t, StringLess>; using DroppedRequestsSnapshotMap = DroppedRequestsMap; struct Snapshot { diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc b/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc index a7666b34e53..9c6e4c553c7 100644 --- a/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc +++ b/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc @@ -346,15 +346,7 @@ grpc_slice XdsLrsRequestCreateAndEncode(const char* server_name) { namespace { void LocalityStatsPopulate(envoy_api_v2_endpoint_UpstreamLocalityStats* output, -#if GRPC_USE_CPP_STD_LIB - // TODO(veblush): Clean up this - // This is to address the difference between - // std::map and Map. #else block will be gone - // once using stdlib is enabled by default. Pair, -#else - Pair, -#endif XdsClientStats::LocalityStats::Snapshot>& input, upb_arena* arena) { // Set sub_zone. diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h b/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h index 1b56bef7d81..25396682bbd 100644 --- a/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h +++ b/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h @@ -57,7 +57,7 @@ class XdsPriorityListUpdate { size_t size() const { return localities.size(); } - Map, Locality, XdsLocalityName::Less> + std::map, Locality, XdsLocalityName::Less> localities; }; diff --git a/src/core/ext/filters/client_channel/lb_policy_factory.h b/src/core/ext/filters/client_channel/lb_policy_factory.h index 3b8c9faa180..3cd6d456714 100644 --- a/src/core/ext/filters/client_channel/lb_policy_factory.h +++ b/src/core/ext/filters/client_channel/lb_policy_factory.h @@ -22,7 +22,6 @@ #include #include "src/core/ext/filters/client_channel/lb_policy.h" -#include "src/core/lib/gprpp/abstract.h" #include "src/core/lib/gprpp/orphanable.h" namespace grpc_core { @@ -31,18 +30,16 @@ class LoadBalancingPolicyFactory { public: /// Returns a new LB policy instance. virtual OrphanablePtr CreateLoadBalancingPolicy( - LoadBalancingPolicy::Args) const GRPC_ABSTRACT; + LoadBalancingPolicy::Args) const = 0; /// Returns the LB policy name that this factory provides. /// Caller does NOT take ownership of result. - virtual const char* name() const GRPC_ABSTRACT; + virtual const char* name() const = 0; virtual RefCountedPtr ParseLoadBalancingConfig( - const grpc_json* json, grpc_error** error) const GRPC_ABSTRACT; + const grpc_json* json, grpc_error** error) const = 0; virtual ~LoadBalancingPolicyFactory() {} - - GRPC_ABSTRACT_BASE_CLASS; }; } // namespace grpc_core diff --git a/src/core/ext/filters/client_channel/resolver.h b/src/core/ext/filters/client_channel/resolver.h index 829a860040a..609d0a7a233 100644 --- a/src/core/ext/filters/client_channel/resolver.h +++ b/src/core/ext/filters/client_channel/resolver.h @@ -25,7 +25,6 @@ #include "src/core/ext/filters/client_channel/server_address.h" #include "src/core/ext/filters/client_channel/service_config.h" -#include "src/core/lib/gprpp/abstract.h" #include "src/core/lib/gprpp/orphanable.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/iomgr/combiner.h" @@ -74,17 +73,15 @@ class Resolver : public InternallyRefCounted { /// Returns a result to the channel. /// Takes ownership of \a result.args. - virtual void ReturnResult(Result result) GRPC_ABSTRACT; // NOLINT + virtual void ReturnResult(Result result) = 0; // NOLINT /// Returns a transient error to the channel. /// If the resolver does not set the GRPC_ERROR_INT_GRPC_STATUS /// attribute on the error, calls will be failed with status UNKNOWN. - virtual void ReturnError(grpc_error* error) GRPC_ABSTRACT; + virtual void ReturnError(grpc_error* error) = 0; // TODO(yashkt): As part of the service config error handling // changes, add a method to parse the service config JSON string. - - GRPC_ABSTRACT_BASE_CLASS }; // Not copyable nor movable. @@ -92,7 +89,7 @@ class Resolver : public InternallyRefCounted { Resolver& operator=(const Resolver&) = delete; /// Starts resolving. - virtual void StartLocked() GRPC_ABSTRACT; + virtual void StartLocked() = 0; /// Asks the resolver to obtain an updated resolver result, if /// applicable. @@ -123,8 +120,6 @@ class Resolver : public InternallyRefCounted { Unref(); } - GRPC_ABSTRACT_BASE_CLASS - protected: GRPC_ALLOW_CLASS_TO_USE_NON_PUBLIC_DELETE @@ -138,7 +133,7 @@ class Resolver : public InternallyRefCounted { virtual ~Resolver(); /// Shuts down the resolver. - virtual void ShutdownLocked() GRPC_ABSTRACT; + virtual void ShutdownLocked() = 0; grpc_combiner* combiner() const { return combiner_; } diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h index 2d172eb3d1e..fe51c34bc3e 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h @@ -23,7 +23,6 @@ #include #include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h" -#include "src/core/lib/gprpp/abstract.h" #include "src/core/lib/iomgr/pollset_set.h" typedef struct grpc_ares_ev_driver grpc_ares_ev_driver; @@ -67,22 +66,18 @@ class GrpcPolledFd { public: virtual ~GrpcPolledFd() {} /* Called when c-ares library is interested and there's no pending callback */ - virtual void RegisterForOnReadableLocked(grpc_closure* read_closure) - GRPC_ABSTRACT; + virtual void RegisterForOnReadableLocked(grpc_closure* read_closure) = 0; /* Called when c-ares library is interested and there's no pending callback */ - virtual void RegisterForOnWriteableLocked(grpc_closure* write_closure) - GRPC_ABSTRACT; + virtual void RegisterForOnWriteableLocked(grpc_closure* write_closure) = 0; /* Indicates if there is data left even after just being read from */ - virtual bool IsFdStillReadableLocked() GRPC_ABSTRACT; + virtual bool IsFdStillReadableLocked() = 0; /* Called once and only once. Must cause cancellation of any pending * read/write callbacks. */ - virtual void ShutdownLocked(grpc_error* error) GRPC_ABSTRACT; + virtual void ShutdownLocked(grpc_error* error) = 0; /* Get the underlying ares_socket_t that this was created from */ - virtual ares_socket_t GetWrappedAresSocketLocked() GRPC_ABSTRACT; + virtual ares_socket_t GetWrappedAresSocketLocked() = 0; /* A unique name, for logging */ - virtual const char* GetName() GRPC_ABSTRACT; - - GRPC_ABSTRACT_BASE_CLASS + virtual const char* GetName() = 0; }; /* A GrpcPolledFdFactory is 1-to-1 with and owned by the @@ -95,11 +90,9 @@ class GrpcPolledFdFactory { /* Creates a new wrapped fd for the current platform */ virtual GrpcPolledFd* NewGrpcPolledFdLocked( ares_socket_t as, grpc_pollset_set* driver_pollset_set, - grpc_combiner* combiner) GRPC_ABSTRACT; + grpc_combiner* combiner) = 0; /* Optionally configures the ares channel after creation */ - virtual void ConfigureAresChannelLocked(ares_channel channel) GRPC_ABSTRACT; - - GRPC_ABSTRACT_BASE_CLASS + virtual void ConfigureAresChannelLocked(ares_channel channel) = 0; }; UniquePtr NewGrpcPolledFdFactory(grpc_combiner* combiner); diff --git a/src/core/ext/filters/client_channel/resolver_factory.h b/src/core/ext/filters/client_channel/resolver_factory.h index 7fed48b9570..7cee4879814 100644 --- a/src/core/ext/filters/client_channel/resolver_factory.h +++ b/src/core/ext/filters/client_channel/resolver_factory.h @@ -24,7 +24,6 @@ #include #include "src/core/ext/filters/client_channel/resolver.h" -#include "src/core/lib/gprpp/abstract.h" #include "src/core/lib/gprpp/memory.h" #include "src/core/lib/gprpp/orphanable.h" #include "src/core/lib/iomgr/pollset_set.h" @@ -49,11 +48,10 @@ class ResolverFactory { public: /// Returns a bool indicating whether the input uri is valid to create a /// resolver. - virtual bool IsValidUri(const grpc_uri* uri) const GRPC_ABSTRACT; + virtual bool IsValidUri(const grpc_uri* uri) const = 0; /// Returns a new resolver instance. - virtual OrphanablePtr CreateResolver(ResolverArgs args) const - GRPC_ABSTRACT; + virtual OrphanablePtr CreateResolver(ResolverArgs args) const = 0; /// Returns a string representing the default authority to use for this /// scheme. @@ -65,11 +63,9 @@ class ResolverFactory { /// Returns the URI scheme that this factory implements. /// Caller does NOT take ownership of result. - virtual const char* scheme() const GRPC_ABSTRACT; + virtual const char* scheme() const = 0; virtual ~ResolverFactory() {} - - GRPC_ABSTRACT_BASE_CLASS }; } // namespace grpc_core diff --git a/src/core/ext/filters/client_channel/service_config.h b/src/core/ext/filters/client_channel/service_config.h index 189a0b9bca2..f0206bf782e 100644 --- a/src/core/ext/filters/client_channel/service_config.h +++ b/src/core/ext/filters/client_channel/service_config.h @@ -62,8 +62,6 @@ class ServiceConfig : public RefCounted { class ParsedConfig { public: virtual ~ParsedConfig() = default; - - GRPC_ABSTRACT_BASE_CLASS; }; /// This is the base class that all service config parsers should derive from. @@ -82,8 +80,6 @@ class ServiceConfig : public RefCounted { GPR_DEBUG_ASSERT(error != nullptr); return nullptr; } - - GRPC_ABSTRACT_BASE_CLASS; }; static constexpr int kNumPreallocatedParsers = 4; diff --git a/src/core/ext/filters/client_channel/subchannel.h b/src/core/ext/filters/client_channel/subchannel.h index d6fb65814b7..d7912a00c77 100644 --- a/src/core/ext/filters/client_channel/subchannel.h +++ b/src/core/ext/filters/client_channel/subchannel.h @@ -192,11 +192,9 @@ class Subchannel { virtual void OnConnectivityStateChange( grpc_connectivity_state new_state, RefCountedPtr connected_subchannel) // NOLINT - GRPC_ABSTRACT; + = 0; - virtual grpc_pollset_set* interested_parties() GRPC_ABSTRACT; - - GRPC_ABSTRACT_BASE_CLASS + virtual grpc_pollset_set* interested_parties() = 0; }; // The ctor and dtor are not intended to use directly. @@ -296,8 +294,8 @@ class Subchannel { private: // TODO(roth): This could be a set instead of a map if we had a set // implementation. - Map> + std::map> watchers_; }; @@ -330,7 +328,7 @@ class Subchannel { private: class HealthWatcher; - Map, StringLess> map_; + std::map, StringLess> map_; }; class ConnectedSubchannelStateWatcher; diff --git a/src/core/ext/filters/client_channel/subchannel_interface.h b/src/core/ext/filters/client_channel/subchannel_interface.h index 2e448dc5a64..9ea3dfe4931 100644 --- a/src/core/ext/filters/client_channel/subchannel_interface.h +++ b/src/core/ext/filters/client_channel/subchannel_interface.h @@ -36,14 +36,12 @@ class SubchannelInterface : public RefCounted { // Will be invoked whenever the subchannel's connectivity state // changes. There will be only one invocation of this method on a // given watcher instance at any given time. - virtual void OnConnectivityStateChange(grpc_connectivity_state new_state) - GRPC_ABSTRACT; + virtual void OnConnectivityStateChange( + grpc_connectivity_state new_state) = 0; // TODO(roth): Remove this as soon as we move to EventManager-based // polling. - virtual grpc_pollset_set* interested_parties() GRPC_ABSTRACT; - - GRPC_ABSTRACT_BASE_CLASS + virtual grpc_pollset_set* interested_parties() = 0; }; template @@ -53,7 +51,7 @@ class SubchannelInterface : public RefCounted { virtual ~SubchannelInterface() = default; // Returns the current connectivity state of the subchannel. - virtual grpc_connectivity_state CheckConnectivityState() GRPC_ABSTRACT; + virtual grpc_connectivity_state CheckConnectivityState() = 0; // Starts watching the subchannel's connectivity state. // The first callback to the watcher will be delivered when the @@ -68,29 +66,27 @@ class SubchannelInterface : public RefCounted { // the previous watcher using CancelConnectivityStateWatch(). virtual void WatchConnectivityState( grpc_connectivity_state initial_state, - UniquePtr watcher) GRPC_ABSTRACT; + UniquePtr watcher) = 0; // Cancels a connectivity state watch. // If the watcher has already been destroyed, this is a no-op. virtual void CancelConnectivityStateWatch( - ConnectivityStateWatcherInterface* watcher) GRPC_ABSTRACT; + ConnectivityStateWatcherInterface* watcher) = 0; // Attempt to connect to the backend. Has no effect if already connected. // If the subchannel is currently in backoff delay due to a previously // failed attempt, the new connection attempt will not start until the // backoff delay has elapsed. - virtual void AttemptToConnect() GRPC_ABSTRACT; + virtual void AttemptToConnect() = 0; // Resets the subchannel's connection backoff state. If AttemptToConnect() // has been called since the subchannel entered TRANSIENT_FAILURE state, // starts a new connection attempt immediately; otherwise, a new connection // attempt will be started as soon as AttemptToConnect() is called. - virtual void ResetBackoff() GRPC_ABSTRACT; + virtual void ResetBackoff() = 0; // TODO(roth): Need a better non-grpc-specific abstraction here. - virtual const grpc_channel_args* channel_args() GRPC_ABSTRACT; - - GRPC_ABSTRACT_BASE_CLASS + virtual const grpc_channel_args* channel_args() = 0; }; } // namespace grpc_core diff --git a/src/core/ext/filters/client_channel/subchannel_pool_interface.h b/src/core/ext/filters/client_channel/subchannel_pool_interface.h index eeb56faf0c0..2fe5fa3fd05 100644 --- a/src/core/ext/filters/client_channel/subchannel_pool_interface.h +++ b/src/core/ext/filters/client_channel/subchannel_pool_interface.h @@ -23,7 +23,6 @@ #include "src/core/lib/avl/avl.h" #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gprpp/abstract.h" #include "src/core/lib/gprpp/ref_counted.h" namespace grpc_core { @@ -70,14 +69,14 @@ class SubchannelPoolInterface : public RefCounted { // with \a key, which may be different from \a constructed because we reuse // (instead of update) any existing subchannel already registered with \a key. virtual Subchannel* RegisterSubchannel(SubchannelKey* key, - Subchannel* constructed) GRPC_ABSTRACT; + Subchannel* constructed) = 0; // Removes the registered subchannel found by \a key. - virtual void UnregisterSubchannel(SubchannelKey* key) GRPC_ABSTRACT; + virtual void UnregisterSubchannel(SubchannelKey* key) = 0; // Finds the subchannel registered for the given subchannel key. Returns NULL // if no such channel exists. Thread-safe. - virtual Subchannel* FindSubchannel(SubchannelKey* key) GRPC_ABSTRACT; + virtual Subchannel* FindSubchannel(SubchannelKey* key) = 0; // Creates a channel arg from \a subchannel pool. static grpc_arg CreateChannelArg(SubchannelPoolInterface* subchannel_pool); @@ -85,8 +84,6 @@ class SubchannelPoolInterface : public RefCounted { // Gets the subchannel pool from the channel args. static SubchannelPoolInterface* GetSubchannelPoolFromChannelArgs( const grpc_channel_args* args); - - GRPC_ABSTRACT_BASE_CLASS }; } // namespace grpc_core diff --git a/src/core/ext/transport/chttp2/transport/flow_control.h b/src/core/ext/transport/chttp2/transport/flow_control.h index 49e206fca3d..39ce1c51ec9 100644 --- a/src/core/ext/transport/chttp2/transport/flow_control.h +++ b/src/core/ext/transport/chttp2/transport/flow_control.h @@ -25,7 +25,6 @@ #include "src/core/ext/transport/chttp2/transport/http2_settings.h" #include "src/core/lib/gpr/useful.h" -#include "src/core/lib/gprpp/abstract.h" #include "src/core/lib/gprpp/manual_constructor.h" #include "src/core/lib/transport/bdp_estimator.h" #include "src/core/lib/transport/pid_controller.h" @@ -189,8 +188,6 @@ class TransportFlowControlBase { // factor virtual void TestOnlyForceHugeWindow() {} - GRPC_ABSTRACT_BASE_CLASS - protected: friend class ::grpc::testing::TrickledCHTTP2; int64_t remote_window_ = kDefaultWindow; @@ -385,8 +382,6 @@ class StreamFlowControlBase { int64_t local_window_delta() { return local_window_delta_; } int64_t announced_window_delta() { return announced_window_delta_; } - GRPC_ABSTRACT_BASE_CLASS - protected: friend class ::grpc::testing::TrickledCHTTP2; int64_t remote_window_delta_ = 0; diff --git a/src/core/lib/channel/channelz.h b/src/core/lib/channel/channelz.h index b023a5280e0..5a063b4df96 100644 --- a/src/core/lib/channel/channelz.h +++ b/src/core/lib/channel/channelz.h @@ -88,7 +88,7 @@ class BaseNode : public RefCounted { virtual ~BaseNode(); // All children must implement this function. - virtual grpc_json* RenderJson() GRPC_ABSTRACT; + virtual grpc_json* RenderJson() = 0; // Renders the json and returns allocated string that must be freed by the // caller. @@ -221,8 +221,8 @@ class ChannelNode : public BaseNode { // TODO(roth): We don't actually use the values here, only the keys, so // these should be sets instead of maps, but we don't currently have a set // implementation. Change this if/when we have one. - Map child_channels_; - Map child_subchannels_; + std::map child_channels_; + std::map child_subchannels_; }; // Handles channelz bookkeeping for servers @@ -262,8 +262,8 @@ class ServerNode : public BaseNode { CallCountingHelper call_counter_; ChannelTrace trace_; Mutex child_mu_; // Guards child maps below. - Map> child_sockets_; - Map> child_listen_sockets_; + std::map> child_sockets_; + std::map> child_listen_sockets_; }; // Handles channelz bookkeeping for sockets diff --git a/src/core/lib/channel/channelz_registry.h b/src/core/lib/channel/channelz_registry.h index e04d7c44888..c60a5554fb9 100644 --- a/src/core/lib/channel/channelz_registry.h +++ b/src/core/lib/channel/channelz_registry.h @@ -87,7 +87,7 @@ class ChannelzRegistry { // protects members Mutex mu_; - Map node_map_; + std::map node_map_; intptr_t uuid_generator_ = 0; }; diff --git a/src/core/lib/channel/handshaker.h b/src/core/lib/channel/handshaker.h index b68799b6e0e..4f064d901df 100644 --- a/src/core/lib/channel/handshaker.h +++ b/src/core/lib/channel/handshaker.h @@ -77,12 +77,11 @@ struct HandshakerArgs { class Handshaker : public RefCounted { public: virtual ~Handshaker() = default; - virtual void Shutdown(grpc_error* why) GRPC_ABSTRACT; + virtual void Shutdown(grpc_error* why) = 0; virtual void DoHandshake(grpc_tcp_server_acceptor* acceptor, grpc_closure* on_handshake_done, - HandshakerArgs* args) GRPC_ABSTRACT; - virtual const char* name() const GRPC_ABSTRACT; - GRPC_ABSTRACT_BASE_CLASS + HandshakerArgs* args) = 0; + virtual const char* name() const = 0; }; // diff --git a/src/core/lib/channel/handshaker_factory.h b/src/core/lib/channel/handshaker_factory.h index 3972af1f439..520e5e4b258 100644 --- a/src/core/lib/channel/handshaker_factory.h +++ b/src/core/lib/channel/handshaker_factory.h @@ -33,10 +33,8 @@ class HandshakerFactory { public: virtual void AddHandshakers(const grpc_channel_args* args, grpc_pollset_set* interested_parties, - HandshakeManager* handshake_mgr) GRPC_ABSTRACT; + HandshakeManager* handshake_mgr) = 0; virtual ~HandshakerFactory() = default; - - GRPC_ABSTRACT_BASE_CLASS }; } // namespace grpc_core diff --git a/src/core/lib/gprpp/abstract.h b/src/core/lib/gprpp/abstract.h deleted file mode 100644 index ea68e3ab041..00000000000 --- a/src/core/lib/gprpp/abstract.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * - * 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_ABSTRACT_H -#define GRPC_CORE_LIB_GPRPP_ABSTRACT_H - -#if GRPC_USE_CPP_STD_LIB - -#define GRPC_ABSTRACT_BASE_CLASS - -#define GRPC_ABSTRACT = 0 - -#else - -// This is needed to support abstract base classes in the c core. Since gRPC -// doesn't have a c++ runtime, it will hit a linker error on delete unless -// we define a virtual operator delete. See this blog for more info: -// https://eli.thegreenplace.net/2015/c-deleting-destructors-and-virtual-operator-delete/ -#define GRPC_ABSTRACT_BASE_CLASS \ - static void operator delete(void* p) { abort(); } - -// gRPC currently can't depend on libstdc++, so we can't use "= 0" for -// pure virtual methods. Instead, we use this macro. -#define GRPC_ABSTRACT \ - { \ - gpr_log(GPR_ERROR, "Function marked GRPC_ABSTRACT was not implemented"); \ - GPR_ASSERT(false); \ - } - -#endif // GRPC_USE_CPP_STD_LIB - -#endif /* GRPC_CORE_LIB_GPRPP_ABSTRACT_H */ diff --git a/src/core/lib/gprpp/map.h b/src/core/lib/gprpp/map.h index 6a41a97bec2..0d61f902757 100644 --- a/src/core/lib/gprpp/map.h +++ b/src/core/lib/gprpp/map.h @@ -26,10 +26,7 @@ #include #include #include - -#if GRPC_USE_CPP_STD_LIB #include -#endif #include "src/core/lib/gpr/useful.h" #include "src/core/lib/gprpp/memory.h" @@ -62,503 +59,6 @@ struct RefCountedPtrLess { } }; -#if GRPC_USE_CPP_STD_LIB - -template > -using Map = std::map; - -#else // GRPC_USE_CPP_STD_LIB - -namespace testing { -class MapTest; -} - -// Alternative map implementation for grpc_core -template > -class Map { - public: - typedef Key key_type; - typedef T mapped_type; - typedef Pair value_type; - typedef Compare key_compare; - class iterator; - class const_iterator; - - Map() = default; - ~Map() { clear(); } - - // Movable. - Map(Map&& other) : root_(other.root_), size_(other.size_) { - other.root_ = nullptr; - other.size_ = 0; - } - Map& operator=(Map&& other) { - if (this != &other) { - clear(); - root_ = other.root_; - size_ = other.size_; - other.root_ = nullptr; - other.size_ = 0; - } - return *this; - } - - // Copyable. - Map(const Map& other) { - for (const auto& p : other) { - emplace(p); - } - } - Map& operator=(const Map& other) { - if (this != &other) { - clear(); - for (const auto& p : other) { - emplace(p); - } - } - return *this; - } - - T& operator[](key_type&& key); - T& operator[](const key_type& key); - iterator find(const key_type& k); - size_t erase(const key_type& key); - // Removes the current entry and points to the next one - iterator erase(iterator iter); - - size_t size() const { return size_; } - - template - Pair emplace(Args&&... args); - - Pair insert(value_type&& pair) { - return emplace(std::move(pair)); - } - - Pair insert(const value_type& pair) { return emplace(pair); } - - bool empty() const { return root_ == nullptr; } - - void clear() { - auto iter = begin(); - while (!empty()) { - iter = erase(iter); - } - } - - iterator begin() { - Entry* curr = GetMinEntry(root_); - return iterator(this, curr); - } - - iterator end() { return iterator(this, nullptr); } - - const_iterator begin() const { - Entry* curr = GetMinEntry(root_); - return const_iterator(this, curr); - } - - const_iterator end() const { return const_iterator(this, nullptr); } - - iterator lower_bound(const Key& k) { - // This is a workaround for "const key_compare compare;" - // because some versions of compilers cannot build this by requiring - // a user-provided constructor. (ref: https://stackoverflow.com/q/7411515) - key_compare compare_tmp; - const key_compare& compare = compare_tmp; - return std::find_if(begin(), end(), [&k, &compare](const value_type& v) { - return !compare(v.first, k); - }); - } - - private: - friend class testing::MapTest; - struct Entry { - explicit Entry(value_type&& pair) : pair(std::move(pair)) {} - value_type pair; - Entry* left = nullptr; - Entry* right = nullptr; - int32_t height = 1; - }; - - static int32_t EntryHeight(const Entry* e) { - return e == nullptr ? 0 : e->height; - } - - static Entry* GetMinEntry(Entry* e); - Entry* InOrderSuccessor(const Entry* e) const; - static Entry* RotateLeft(Entry* e); - static Entry* RotateRight(Entry* e); - static Entry* RebalanceTreeAfterInsertion(Entry* root, const key_type& k); - static Entry* RebalanceTreeAfterDeletion(Entry* root); - // Returns a pair with the first value being an iterator pointing to the - // inserted entry and the second value being the new root of the subtree - // after a rebalance - Pair InsertRecursive(Entry* root, value_type&& p); - // Returns a pair with the first value being an iterator pointing to the - // successor of the deleted entry and the second value being the new root of - // the subtree after a rebalance - Pair RemoveRecursive(Entry* root, const key_type& k); - // Return 0 if lhs = rhs - // 1 if lhs > rhs - // -1 if lhs < rhs - static int CompareKeys(const Key& lhs, const Key& rhs); - - Entry* root_ = nullptr; - size_t size_ = 0; -}; - -template -class Map::iterator - : public std::iterator, int32_t, - Pair*, Pair&> { - public: - iterator(const iterator& iter) : curr_(iter.curr_), map_(iter.map_) {} - bool operator==(const iterator& rhs) const { return (curr_ == rhs.curr_); } - bool operator!=(const iterator& rhs) const { return (curr_ != rhs.curr_); } - - iterator& operator++() { - curr_ = map_->InOrderSuccessor(curr_); - return *this; - } - - iterator operator++(int) { - Entry* prev = curr_; - curr_ = map_->InOrderSuccessor(curr_); - return iterator(map_, prev); - } - - iterator& operator=(const iterator& other) { - if (this != &other) { - this->curr_ = other.curr_; - this->map_ = other.map_; - } - return *this; - } - - // operator*() - value_type& operator*() { return curr_->pair; } - const value_type& operator*() const { return curr_->pair; } - - // operator->() - value_type* operator->() { return &curr_->pair; } - value_type const* operator->() const { return &curr_->pair; } - - private: - friend class Map; - using GrpcMap = typename ::grpc_core::Map; - iterator(GrpcMap* map, Entry* curr) : curr_(curr), map_(map) {} - Entry* curr_; - GrpcMap* map_; -}; - -template -class Map::const_iterator - : public std::iterator, int32_t, - Pair*, Pair&> { - public: - const_iterator(const const_iterator& iter) - : curr_(iter.curr_), map_(iter.map_) {} - bool operator==(const const_iterator& rhs) const { - return (curr_ == rhs.curr_); - } - bool operator!=(const const_iterator& rhs) const { - return (curr_ != rhs.curr_); - } - - const_iterator& operator++() { - curr_ = map_->InOrderSuccessor(curr_); - return *this; - } - - const_iterator operator++(int) { - Entry* prev = curr_; - curr_ = map_->InOrderSuccessor(curr_); - return const_iterator(map_, prev); - } - - const_iterator& operator=(const const_iterator& other) { - if (this != &other) { - this->curr_ = other.curr_; - this->map_ = other.map_; - } - return *this; - } - - // operator*() - const value_type& operator*() const { return curr_->pair; } - - // operator->() - const value_type* operator->() const { return &curr_->pair; } - - private: - friend class Map; - using GrpcMap = typename ::grpc_core::Map; - const_iterator(const GrpcMap* map, Entry* curr) : curr_(curr), map_(map) {} - Entry* curr_; - const GrpcMap* map_; -}; - -template -T& Map::operator[](key_type&& key) { - auto iter = find(key); - if (iter == end()) { - return emplace(std::move(key), T()).first->second; - } - return iter->second; -} - -template -T& Map::operator[](const key_type& key) { - auto iter = find(key); - if (iter == end()) { - return emplace(key, T()).first->second; - } - return iter->second; -} - -template -typename Map::iterator Map::find( - const key_type& k) { - Entry* iter = root_; - while (iter != nullptr) { - int comp = CompareKeys(iter->pair.first, k); - if (comp == 0) { - return iterator(this, iter); - } else if (comp < 0) { - iter = iter->right; - } else { - iter = iter->left; - } - } - return end(); -} - -template -template -typename ::grpc_core::Pair::iterator, bool> -Map::emplace(Args&&... args) { - Pair pair(std::forward(args)...); - iterator ret = find(pair.first); - bool insertion = false; - if (ret == end()) { - Pair p = InsertRecursive(root_, std::move(pair)); - root_ = p.second; - ret = p.first; - insertion = true; - size_++; - } - return MakePair(ret, insertion); -} - -template -size_t Map::erase(const key_type& key) { - iterator it = find(key); - if (it == end()) return 0; - erase(it); - return 1; -} - -// TODO(mhaidry): Modify erase to use the iterator location -// to create an efficient erase method -template -typename Map::iterator Map::erase( - iterator iter) { - if (iter == end()) return iter; - key_type& del_key = iter->first; - Pair ret = RemoveRecursive(root_, del_key); - root_ = ret.second; - size_--; - return ret.first; -} - -template -typename Map::Entry* Map::InOrderSuccessor( - const Entry* e) const { - if (e->right != nullptr) { - return GetMinEntry(e->right); - } - Entry* successor = nullptr; - Entry* iter = root_; - while (iter != nullptr) { - int comp = CompareKeys(iter->pair.first, e->pair.first); - if (comp > 0) { - successor = iter; - iter = iter->left; - } else if (comp < 0) { - iter = iter->right; - } else - break; - } - return successor; -} - -// Returns a pair with the first value being an iterator pointing to the -// inserted entry and the second value being the new root of the subtree -// after a rebalance -template -typename ::grpc_core::Pair::iterator, - typename Map::Entry*> -Map::InsertRecursive(Entry* root, value_type&& p) { - if (root == nullptr) { - Entry* e = New(std::move(p)); - return MakePair(iterator(this, e), e); - } - int comp = CompareKeys(root->pair.first, p.first); - if (comp > 0) { - Pair ret = InsertRecursive(root->left, std::move(p)); - root->left = ret.second; - ret.second = RebalanceTreeAfterInsertion(root, ret.first->first); - return ret; - } else if (comp < 0) { - Pair ret = InsertRecursive(root->right, std::move(p)); - root->right = ret.second; - ret.second = RebalanceTreeAfterInsertion(root, ret.first->first); - return ret; - } else { - root->pair = std::move(p); - return MakePair(iterator(this, root), root); - } -} - -template -typename Map::Entry* Map::GetMinEntry( - Entry* e) { - if (e != nullptr) { - while (e->left != nullptr) { - e = e->left; - } - } - return e; -} - -template -typename Map::Entry* Map::RotateLeft( - Entry* e) { - Entry* rightChild = e->right; - Entry* rightLeftChild = rightChild->left; - rightChild->left = e; - e->right = rightLeftChild; - e->height = 1 + GPR_MAX(EntryHeight(e->left), EntryHeight(e->right)); - rightChild->height = 1 + GPR_MAX(EntryHeight(rightChild->left), - EntryHeight(rightChild->right)); - return rightChild; -} - -template -typename Map::Entry* Map::RotateRight( - Entry* e) { - Entry* leftChild = e->left; - Entry* leftRightChild = leftChild->right; - leftChild->right = e; - e->left = leftRightChild; - e->height = 1 + GPR_MAX(EntryHeight(e->left), EntryHeight(e->right)); - leftChild->height = - 1 + GPR_MAX(EntryHeight(leftChild->left), EntryHeight(leftChild->right)); - return leftChild; -} - -template -typename Map::Entry* -Map::RebalanceTreeAfterInsertion(Entry* root, - const key_type& k) { - root->height = 1 + GPR_MAX(EntryHeight(root->left), EntryHeight(root->right)); - int32_t heightDifference = EntryHeight(root->left) - EntryHeight(root->right); - if (heightDifference > 1 && CompareKeys(root->left->pair.first, k) > 0) { - return RotateRight(root); - } - if (heightDifference < -1 && CompareKeys(root->right->pair.first, k) < 0) { - return RotateLeft(root); - } - if (heightDifference > 1 && CompareKeys(root->left->pair.first, k) < 0) { - root->left = RotateLeft(root->left); - return RotateRight(root); - } - if (heightDifference < -1 && CompareKeys(root->right->pair.first, k) > 0) { - root->right = RotateRight(root->right); - return RotateLeft(root); - } - return root; -} - -template -typename Map::Entry* -Map::RebalanceTreeAfterDeletion(Entry* root) { - root->height = 1 + GPR_MAX(EntryHeight(root->left), EntryHeight(root->right)); - int32_t heightDifference = EntryHeight(root->left) - EntryHeight(root->right); - if (heightDifference > 1) { - int leftHeightDifference = - EntryHeight(root->left->left) - EntryHeight(root->left->right); - if (leftHeightDifference < 0) { - root->left = RotateLeft(root->left); - } - return RotateRight(root); - } - if (heightDifference < -1) { - int rightHeightDifference = - EntryHeight(root->right->left) - EntryHeight(root->right->right); - if (rightHeightDifference > 0) { - root->right = RotateRight(root->right); - } - return RotateLeft(root); - } - return root; -} - -template -typename ::grpc_core::Pair::iterator, - typename Map::Entry*> -Map::RemoveRecursive(Entry* root, const key_type& k) { - Pair ret = MakePair(end(), root); - if (root == nullptr) return ret; - int comp = CompareKeys(root->pair.first, k); - if (comp > 0) { - ret = RemoveRecursive(root->left, k); - root->left = ret.second; - } else if (comp < 0) { - ret = RemoveRecursive(root->right, k); - root->right = ret.second; - } else { - Entry* entry; - Entry* successor = InOrderSuccessor(root); - if (root->left == nullptr) { - entry = root->right; - Delete(root); - return MakePair(iterator(this, successor), entry); - } else if (root->right == nullptr) { - entry = root->left; - Delete(root); - return MakePair(iterator(this, successor), entry); - } else { - entry = successor; - root->pair.swap(entry->pair); - ret = RemoveRecursive(root->right, entry->pair.first); - root->right = ret.second; - ret.first = iterator(this, root); - } - } - return MakePair(ret.first, RebalanceTreeAfterDeletion(root)); -} - -template -int Map::CompareKeys(const key_type& lhs, - const key_type& rhs) { - // This is a workaround for "const key_compare compare;" - // because some versions of compilers cannot build this by requiring - // a user-provided constructor. (ref: https://stackoverflow.com/q/7411515) - key_compare compare_tmp; - const key_compare& compare = compare_tmp; - bool left_comparison = compare(lhs, rhs); - bool right_comparison = compare(rhs, lhs); - // Both values are equal - if (!left_comparison && !right_comparison) { - return 0; - } - return left_comparison ? -1 : 1; -} - -#endif // GRPC_USE_CPP_STD_LIB - } // namespace grpc_core #endif /* GRPC_CORE_LIB_GPRPP_MAP_H */ diff --git a/src/core/lib/gprpp/orphanable.h b/src/core/lib/gprpp/orphanable.h index ab02d80827b..03511e8a4db 100644 --- a/src/core/lib/gprpp/orphanable.h +++ b/src/core/lib/gprpp/orphanable.h @@ -28,7 +28,6 @@ #include #include "src/core/lib/debug/trace.h" -#include "src/core/lib/gprpp/abstract.h" #include "src/core/lib/gprpp/debug_location.h" #include "src/core/lib/gprpp/memory.h" #include "src/core/lib/gprpp/ref_counted.h" @@ -46,14 +45,12 @@ class Orphanable { // Gives up ownership of the object. The implementation must arrange // to eventually destroy the object without further interaction from the // caller. - virtual void Orphan() GRPC_ABSTRACT; + virtual void Orphan() = 0; // Not copyable or movable. Orphanable(const Orphanable&) = delete; Orphanable& operator=(const Orphanable&) = delete; - GRPC_ABSTRACT_BASE_CLASS - protected: Orphanable() {} virtual ~Orphanable() {} @@ -83,8 +80,6 @@ class InternallyRefCounted : public Orphanable { InternallyRefCounted(const InternallyRefCounted&) = delete; InternallyRefCounted& operator=(const InternallyRefCounted&) = delete; - GRPC_ABSTRACT_BASE_CLASS - protected: GRPC_ALLOW_CLASS_TO_USE_NON_PUBLIC_DELETE diff --git a/src/core/lib/gprpp/ref_counted.h b/src/core/lib/gprpp/ref_counted.h index 5c7a5cf0735..086156f2d74 100644 --- a/src/core/lib/gprpp/ref_counted.h +++ b/src/core/lib/gprpp/ref_counted.h @@ -30,7 +30,6 @@ #include #include "src/core/lib/debug/trace.h" -#include "src/core/lib/gprpp/abstract.h" #include "src/core/lib/gprpp/atomic.h" #include "src/core/lib/gprpp/debug_location.h" #include "src/core/lib/gprpp/memory.h" @@ -40,9 +39,6 @@ namespace grpc_core { // PolymorphicRefCount enforces polymorphic destruction of RefCounted. class PolymorphicRefCount { - public: - GRPC_ABSTRACT_BASE_CLASS - protected: GRPC_ALLOW_CLASS_TO_USE_NON_PUBLIC_DELETE @@ -53,9 +49,6 @@ class PolymorphicRefCount { // RefCounted. Please refer to grpc_core::RefCounted for more details, and // when in doubt use PolymorphicRefCount. class NonPolymorphicRefCount { - public: - GRPC_ABSTRACT_BASE_CLASS - protected: GRPC_ALLOW_CLASS_TO_USE_NON_PUBLIC_DELETE @@ -272,8 +265,6 @@ class RefCounted : public Impl { RefCounted(const RefCounted&) = delete; RefCounted& operator=(const RefCounted&) = delete; - GRPC_ABSTRACT_BASE_CLASS - protected: GRPC_ALLOW_CLASS_TO_USE_NON_PUBLIC_DELETE diff --git a/src/core/lib/gprpp/thd.h b/src/core/lib/gprpp/thd.h index 0af33faa119..223e4115b87 100644 --- a/src/core/lib/gprpp/thd.h +++ b/src/core/lib/gprpp/thd.h @@ -28,7 +28,6 @@ #include #include -#include "src/core/lib/gprpp/abstract.h" #include "src/core/lib/gprpp/memory.h" namespace grpc_core { @@ -38,9 +37,8 @@ namespace internal { class ThreadInternalsInterface { public: virtual ~ThreadInternalsInterface() {} - virtual void Start() GRPC_ABSTRACT; - virtual void Join() GRPC_ABSTRACT; - GRPC_ABSTRACT_BASE_CLASS + virtual void Start() = 0; + virtual void Join() = 0; }; } // namespace internal diff --git a/src/core/lib/iomgr/executor/mpmcqueue.h b/src/core/lib/iomgr/executor/mpmcqueue.h index ab5c484e094..474f40bbf87 100644 --- a/src/core/lib/iomgr/executor/mpmcqueue.h +++ b/src/core/lib/iomgr/executor/mpmcqueue.h @@ -22,7 +22,6 @@ #include #include "src/core/lib/debug/stats.h" -#include "src/core/lib/gprpp/abstract.h" #include "src/core/lib/gprpp/atomic.h" #include "src/core/lib/gprpp/sync.h" @@ -38,17 +37,15 @@ class MPMCQueueInterface { // Puts elem into queue immediately at the end of queue. // This might cause to block on full queue depending on implementation. - virtual void Put(void* elem) GRPC_ABSTRACT; + virtual void Put(void* elem) = 0; // Removes the oldest element from the queue and return it. // This might cause to block on empty queue depending on implementation. // Optional argument for collecting stats purpose. - virtual void* Get(gpr_timespec* wait_time = nullptr) GRPC_ABSTRACT; + virtual void* Get(gpr_timespec* wait_time = nullptr) = 0; // Returns number of elements in the queue currently - virtual int count() const GRPC_ABSTRACT; - - GRPC_ABSTRACT_BASE_CLASS + virtual int count() const = 0; }; class InfLenFIFOQueue : public MPMCQueueInterface { diff --git a/src/core/lib/iomgr/executor/threadpool.h b/src/core/lib/iomgr/executor/threadpool.h index 7b33fb32f36..0402c6ddf0e 100644 --- a/src/core/lib/iomgr/executor/threadpool.h +++ b/src/core/lib/iomgr/executor/threadpool.h @@ -43,22 +43,19 @@ class ThreadPoolInterface { // current thread to be blocked (in case of unable to schedule). // Closure should contain a function pointer and arguments it will take, more // details for closure struct at /grpc/include/grpc/impl/codegen/grpc_types.h - virtual void Add(grpc_experimental_completion_queue_functor* closure) - GRPC_ABSTRACT; + virtual void Add(grpc_experimental_completion_queue_functor* closure) = 0; // Returns the current number of pending closures - virtual int num_pending_closures() const GRPC_ABSTRACT; + virtual int num_pending_closures() const = 0; // Returns the capacity of pool (number of worker threads in pool) - virtual int pool_capacity() const GRPC_ABSTRACT; + virtual int pool_capacity() const = 0; // Thread option accessor - virtual const Thread::Options& thread_options() const GRPC_ABSTRACT; + virtual const Thread::Options& thread_options() const = 0; // Returns the thread name for threads in this ThreadPool. - virtual const char* thread_name() const GRPC_ABSTRACT; - - GRPC_ABSTRACT_BASE_CLASS + virtual const char* thread_name() const = 0; }; // Worker thread for threadpool. Executes closures in the queue, until getting a diff --git a/src/core/lib/iomgr/tcp_server.h b/src/core/lib/iomgr/tcp_server.h index 0d16b66230f..0af8a7953ed 100644 --- a/src/core/lib/iomgr/tcp_server.h +++ b/src/core/lib/iomgr/tcp_server.h @@ -24,7 +24,6 @@ #include #include -#include "src/core/lib/gprpp/abstract.h" #include "src/core/lib/iomgr/closure.h" #include "src/core/lib/iomgr/endpoint.h" #include "src/core/lib/iomgr/resolve_address.h" @@ -57,9 +56,7 @@ class TcpServerFdHandler { public: virtual ~TcpServerFdHandler() = default; virtual void Handle(int listener_fd, int fd, - grpc_byte_buffer* pending_read) GRPC_ABSTRACT; - - GRPC_ABSTRACT_BASE_CLASS; + grpc_byte_buffer* pending_read) = 0; }; } // namespace grpc_core diff --git a/src/core/lib/iomgr/udp_server.h b/src/core/lib/iomgr/udp_server.h index 3656791c1f8..759917ee4e4 100644 --- a/src/core/lib/iomgr/udp_server.h +++ b/src/core/lib/iomgr/udp_server.h @@ -21,7 +21,6 @@ #include -#include "src/core/lib/gprpp/abstract.h" #include "src/core/lib/iomgr/endpoint.h" #include "src/core/lib/iomgr/ev_posix.h" #include "src/core/lib/iomgr/resolve_address.h" @@ -47,18 +46,16 @@ class GrpcUdpHandler { // Called when data is available to read from the socket. Returns true if // there is more data to read after this call. - virtual bool Read() GRPC_ABSTRACT; + virtual bool Read() = 0; // Called when socket becomes write unblocked. The given closure should be // scheduled when the socket becomes blocked next time. virtual void OnCanWrite(void* user_data, - grpc_closure* notify_on_write_closure) GRPC_ABSTRACT; + grpc_closure* notify_on_write_closure) = 0; // Called before the gRPC FD is orphaned. Notify udp server to continue // orphaning fd by scheduling the given closure, afterwards the associated fd // will be closed. virtual void OnFdAboutToOrphan(grpc_closure* orphan_fd_closure, - void* user_data) GRPC_ABSTRACT; - - GRPC_ABSTRACT_BASE_CLASS + void* user_data) = 0; }; class GrpcUdpHandlerFactory { @@ -67,11 +64,8 @@ class GrpcUdpHandlerFactory { /* Called when start to listen on a socket. * Return an instance of the implementation of GrpcUdpHandler interface which * will process I/O events for this socket from now on. */ - virtual GrpcUdpHandler* CreateUdpHandler(grpc_fd* emfd, - void* user_data) GRPC_ABSTRACT; - virtual void DestroyUdpHandler(GrpcUdpHandler* handler) GRPC_ABSTRACT; - - GRPC_ABSTRACT_BASE_CLASS + virtual GrpcUdpHandler* CreateUdpHandler(grpc_fd* emfd, void* user_data) = 0; + virtual void DestroyUdpHandler(GrpcUdpHandler* handler) = 0; }; /* Create a server, initially not bound to any ports */ diff --git a/src/core/lib/security/credentials/credentials.cc b/src/core/lib/security/credentials/credentials.cc index f2ec9b7f2f2..37678715704 100644 --- a/src/core/lib/security/credentials/credentials.cc +++ b/src/core/lib/security/credentials/credentials.cc @@ -45,18 +45,18 @@ void grpc_channel_credentials_release(grpc_channel_credentials* creds) { if (creds) creds->Unref(); } -static grpc_core::Map, - grpc_core::RefCountedPtr, - grpc_core::StringLess>* g_grpc_control_plane_creds; +static std::map, + grpc_core::RefCountedPtr, + grpc_core::StringLess>* g_grpc_control_plane_creds; static gpr_mu g_control_plane_creds_mu; static void do_control_plane_creds_init() { gpr_mu_init(&g_control_plane_creds_mu); GPR_ASSERT(g_grpc_control_plane_creds == nullptr); g_grpc_control_plane_creds = grpc_core::New< - grpc_core::Map, - grpc_core::RefCountedPtr, - grpc_core::StringLess>>(); + std::map, + grpc_core::RefCountedPtr, + grpc_core::StringLess>>(); } void grpc_control_plane_credentials_init() { diff --git a/src/core/lib/security/credentials/credentials.h b/src/core/lib/security/credentials/credentials.h index b43405b0861..e0700c41a92 100644 --- a/src/core/lib/security/credentials/credentials.h +++ b/src/core/lib/security/credentials/credentials.h @@ -110,17 +110,7 @@ struct grpc_channel_credentials create_security_connector( grpc_core::RefCountedPtr call_creds, const char* target, const grpc_channel_args* args, - grpc_channel_args** new_args) -#if GRPC_USE_CPP_STD_LIB - = 0; -#else - { - // Tell clang-tidy that call_creds cannot be passed as const-ref. - call_creds.reset(); - gpr_log(GPR_ERROR, "Function marked GRPC_ABSTRACT was not implemented"); - GPR_ASSERT(false); - } -#endif + grpc_channel_args** new_args) = 0; // Creates a version of the channel credentials without any attached call // credentials. This can be used in order to open a channel to a non-trusted @@ -156,13 +146,11 @@ struct grpc_channel_credentials const char* type() const { return type_; } - GRPC_ABSTRACT_BASE_CLASS - private: const char* type_; - grpc_core::Map, - grpc_core::RefCountedPtr, - grpc_core::StringLess> + std::map, + grpc_core::RefCountedPtr, + grpc_core::StringLess> local_control_plane_creds_; }; @@ -248,18 +236,16 @@ struct grpc_call_credentials grpc_auth_metadata_context context, grpc_credentials_mdelem_array* md_array, grpc_closure* on_request_metadata, - grpc_error** error) GRPC_ABSTRACT; + grpc_error** error) = 0; // Cancels a pending asynchronous operation started by // grpc_call_credentials_get_request_metadata() with the corresponding // value of \a md_array. virtual void cancel_get_request_metadata( - grpc_credentials_mdelem_array* md_array, grpc_error* error) GRPC_ABSTRACT; + grpc_credentials_mdelem_array* md_array, grpc_error* error) = 0; const char* type() const { return type_; } - GRPC_ABSTRACT_BASE_CLASS - private: const char* type_; }; @@ -282,7 +268,7 @@ struct grpc_server_credentials virtual ~grpc_server_credentials() { DestroyProcessor(); } virtual grpc_core::RefCountedPtr - create_security_connector() GRPC_ABSTRACT; + create_security_connector() = 0; const char* type() const { return type_; } @@ -292,8 +278,6 @@ struct grpc_server_credentials void set_auth_metadata_processor( const grpc_auth_metadata_processor& processor); - GRPC_ABSTRACT_BASE_CLASS - private: void DestroyProcessor() { if (processor_.destroy != nullptr && processor_.state != nullptr) { diff --git a/src/core/lib/security/credentials/oauth2/oauth2_credentials.h b/src/core/lib/security/credentials/oauth2/oauth2_credentials.h index c9b2d1decac..ba07ee04ee7 100644 --- a/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +++ b/src/core/lib/security/credentials/oauth2/oauth2_credentials.h @@ -85,13 +85,11 @@ class grpc_oauth2_token_fetcher_credentials : public grpc_call_credentials { void on_http_response(grpc_credentials_metadata_request* r, grpc_error* error); - GRPC_ABSTRACT_BASE_CLASS - protected: virtual void fetch_oauth2(grpc_credentials_metadata_request* req, grpc_httpcli_context* httpcli_context, grpc_polling_entity* pollent, grpc_iomgr_cb_func cb, - grpc_millis deadline) GRPC_ABSTRACT; + grpc_millis deadline) = 0; private: gpr_mu mu_; diff --git a/src/core/lib/security/security_connector/security_connector.h b/src/core/lib/security/security_connector/security_connector.h index 2e573d65dfe..39e56bcc59a 100644 --- a/src/core/lib/security/security_connector/security_connector.h +++ b/src/core/lib/security/security_connector/security_connector.h @@ -58,15 +58,13 @@ class grpc_security_connector virtual void check_peer( tsi_peer peer, grpc_endpoint* ep, grpc_core::RefCountedPtr* auth_context, - grpc_closure* on_peer_checked) GRPC_ABSTRACT; + grpc_closure* on_peer_checked) = 0; /* Compares two security connectors. */ - virtual int cmp(const grpc_security_connector* other) const GRPC_ABSTRACT; + virtual int cmp(const grpc_security_connector* other) const = 0; const char* url_scheme() const { return url_scheme_; } - GRPC_ABSTRACT_BASE_CLASS - private: const char* url_scheme_; }; @@ -103,16 +101,16 @@ class grpc_channel_security_connector : public grpc_security_connector { virtual bool check_call_host(grpc_core::StringView host, grpc_auth_context* auth_context, grpc_closure* on_call_host_checked, - grpc_error** error) GRPC_ABSTRACT; + grpc_error** error) = 0; /// Cancels a pending asynchronous call to /// grpc_channel_security_connector_check_call_host() with /// \a on_call_host_checked as its callback. virtual void cancel_check_call_host(grpc_closure* on_call_host_checked, - grpc_error* error) GRPC_ABSTRACT; + grpc_error* error) = 0; /// Registers handshakers with \a handshake_mgr. - virtual void add_handshakers( - const grpc_channel_args* args, grpc_pollset_set* interested_parties, - grpc_core::HandshakeManager* handshake_mgr) GRPC_ABSTRACT; + virtual void add_handshakers(const grpc_channel_args* args, + grpc_pollset_set* interested_parties, + grpc_core::HandshakeManager* handshake_mgr) = 0; const grpc_channel_credentials* channel_creds() const { return channel_creds_.get(); @@ -127,8 +125,6 @@ class grpc_channel_security_connector : public grpc_security_connector { return request_metadata_creds_.get(); } - GRPC_ABSTRACT_BASE_CLASS - protected: // Helper methods to be used in subclasses. int channel_security_connector_cmp( @@ -157,9 +153,9 @@ class grpc_server_security_connector : public grpc_security_connector { grpc_core::RefCountedPtr server_creds); ~grpc_server_security_connector() override = default; - virtual void add_handshakers( - const grpc_channel_args* args, grpc_pollset_set* interested_parties, - grpc_core::HandshakeManager* handshake_mgr) GRPC_ABSTRACT; + virtual void add_handshakers(const grpc_channel_args* args, + grpc_pollset_set* interested_parties, + grpc_core::HandshakeManager* handshake_mgr) = 0; const grpc_server_credentials* server_creds() const { return server_creds_.get(); @@ -168,8 +164,6 @@ class grpc_server_security_connector : public grpc_security_connector { return server_creds_.get(); } - GRPC_ABSTRACT_BASE_CLASS - protected: // Helper methods to be used in subclasses. int server_security_connector_cmp( diff --git a/src/core/lib/surface/completion_queue.h b/src/core/lib/surface/completion_queue.h index dc13bc50f91..4a114be8285 100644 --- a/src/core/lib/surface/completion_queue.h +++ b/src/core/lib/surface/completion_queue.h @@ -26,7 +26,6 @@ #include #include "src/core/lib/debug/trace.h" -#include "src/core/lib/gprpp/abstract.h" #include "src/core/lib/gprpp/manual_constructor.h" #include "src/core/lib/iomgr/pollset.h" diff --git a/src/core/lib/transport/byte_stream.h b/src/core/lib/transport/byte_stream.h index 06503015d2c..5ffa63bad1a 100644 --- a/src/core/lib/transport/byte_stream.h +++ b/src/core/lib/transport/byte_stream.h @@ -22,7 +22,6 @@ #include #include -#include "src/core/lib/gprpp/abstract.h" #include "src/core/lib/gprpp/orphanable.h" #include "src/core/lib/iomgr/closure.h" @@ -45,14 +44,13 @@ class ByteStream : public Orphanable { // // max_size_hint can be set as a hint as to the maximum number // of bytes that would be acceptable to read. - virtual bool Next(size_t max_size_hint, - grpc_closure* on_complete) GRPC_ABSTRACT; + virtual bool Next(size_t max_size_hint, grpc_closure* on_complete) = 0; // Returns the next slice in the byte stream when it is available, as // indicated by Next(). // // Once a slice is returned into *slice, it is owned by the caller. - virtual grpc_error* Pull(grpc_slice* slice) GRPC_ABSTRACT; + virtual grpc_error* Pull(grpc_slice* slice) = 0; // Shuts down the byte stream. // @@ -61,15 +59,13 @@ class ByteStream : public Orphanable { // // The next call to Pull() (if any) will return the error passed to // Shutdown(). - virtual void Shutdown(grpc_error* error) GRPC_ABSTRACT; + virtual void Shutdown(grpc_error* error) = 0; uint32_t length() const { return length_; } uint32_t flags() const { return flags_; } void set_flags(uint32_t flags) { flags_ = flags; } - GRPC_ABSTRACT_BASE_CLASS - protected: ByteStream(uint32_t length, uint32_t flags) : length_(length), flags_(flags) {} diff --git a/src/core/lib/transport/connectivity_state.h b/src/core/lib/transport/connectivity_state.h index 25b43561364..cefd1b88a02 100644 --- a/src/core/lib/transport/connectivity_state.h +++ b/src/core/lib/transport/connectivity_state.h @@ -47,11 +47,9 @@ class ConnectivityStateWatcherInterface virtual ~ConnectivityStateWatcherInterface() = default; // Notifies the watcher that the state has changed to new_state. - virtual void Notify(grpc_connectivity_state new_state) GRPC_ABSTRACT; + virtual void Notify(grpc_connectivity_state new_state) = 0; void Orphan() override { Unref(); } - - GRPC_ABSTRACT_BASE_CLASS }; // An alternative watcher interface that performs notifications via an @@ -70,8 +68,7 @@ class AsyncConnectivityStateWatcherInterface class Notifier; // Invoked asynchronously when Notify() is called. - virtual void OnConnectivityStateChange(grpc_connectivity_state new_state) - GRPC_ABSTRACT; + virtual void OnConnectivityStateChange(grpc_connectivity_state new_state) = 0; }; // Tracks connectivity state. Maintains a list of watchers that are @@ -113,8 +110,8 @@ class ConnectivityStateTracker { Atomic state_; // TODO(roth): This could be a set instead of a map if we had a set // implementation. - Map> + std::map> watchers_; }; diff --git a/src/core/tsi/ssl/session_cache/ssl_session.h b/src/core/tsi/ssl/session_cache/ssl_session.h index e847267cb30..6188637464f 100644 --- a/src/core/tsi/ssl/session_cache/ssl_session.h +++ b/src/core/tsi/ssl/session_cache/ssl_session.h @@ -62,9 +62,7 @@ class SslCachedSession { virtual ~SslCachedSession() = default; /// Returns a copy of previously cached session. - virtual SslSessionPtr CopySession() const GRPC_ABSTRACT; - - GRPC_ABSTRACT_BASE_CLASS + virtual SslSessionPtr CopySession() const = 0; protected: SslCachedSession() = default; diff --git a/test/core/gprpp/BUILD b/test/core/gprpp/BUILD index 193ef5e410a..017a5b9fdba 100644 --- a/test/core/gprpp/BUILD +++ b/test/core/gprpp/BUILD @@ -81,20 +81,6 @@ grpc_cc_test( uses_polling = False, ) -grpc_cc_test( - name = "grpc_core_map_test", - srcs = ["map_test.cc"], - external_deps = [ - "gtest", - ], - language = "C++", - deps = [ - "//:gpr_base", - "//test/core/util:grpc_test_util", - ], - uses_polling = False, -) - grpc_cc_test( name = "memory_test", srcs = ["memory_test.cc"], diff --git a/test/core/gprpp/manual_constructor_test.cc b/test/core/gprpp/manual_constructor_test.cc index a5a45133d86..5f41920391a 100644 --- a/test/core/gprpp/manual_constructor_test.cc +++ b/test/core/gprpp/manual_constructor_test.cc @@ -26,7 +26,6 @@ #include #include -#include "src/core/lib/gprpp/abstract.h" #include "test/core/util/test_config.h" class A { @@ -35,7 +34,6 @@ class A { virtual ~A() {} virtual const char* foo() { return "A_foo"; } virtual const char* bar() { return "A_bar"; } - GRPC_ABSTRACT_BASE_CLASS }; class B : public A { diff --git a/test/core/gprpp/map_test.cc b/test/core/gprpp/map_test.cc deleted file mode 100644 index 7dc1ba636f3..00000000000 --- a/test/core/gprpp/map_test.cc +++ /dev/null @@ -1,514 +0,0 @@ -/* - * - * 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. - * - */ - -#include "src/core/lib/gprpp/map.h" - -#include - -#include "include/grpc/support/string_util.h" -#include "src/core/lib/gprpp/inlined_vector.h" -#include "src/core/lib/gprpp/memory.h" -#include "src/core/lib/gprpp/orphanable.h" -#include "src/core/lib/gprpp/ref_counted_ptr.h" -#include "test/core/util/test_config.h" - -namespace grpc_core { -namespace testing { - -#if GRPC_USE_CPP_STD_LIB - -TEST(MapTest, Nop) {} - -#else - -class Payload { - public: - Payload() : data_(-1) {} - explicit Payload(int data) : data_(data) {} - Payload(const Payload& other) : data_(other.data_) {} - Payload& operator=(const Payload& other) { - if (this != &other) { - data_ = other.data_; - } - return *this; - } - int data() { return data_; } - - private: - int data_; -}; - -inline UniquePtr CopyString(const char* string) { - return UniquePtr(gpr_strdup(string)); -} - -static constexpr char kKeys[][4] = {"abc", "efg", "hij", "klm", "xyz"}; - -class MapTest : public ::testing::Test { - public: - template - typename ::grpc_core::Map::Entry* Root( - typename ::grpc_core::Map* map) { - return map->root_; - } -}; - -// Test insertion of Payload -TEST_F(MapTest, EmplaceAndFind) { - Map test_map; - for (int i = 0; i < 5; i++) { - test_map.emplace(kKeys[i], Payload(i)); - } - for (int i = 0; i < 5; i++) { - EXPECT_EQ(i, test_map.find(kKeys[i])->second.data()); - } -} - -// Test insertion of Payload Unique Ptrs -TEST_F(MapTest, EmplaceAndFindWithUniquePtrValue) { - Map, StringLess> test_map; - for (int i = 0; i < 5; i++) { - test_map.emplace(kKeys[i], MakeUnique(i)); - } - for (int i = 0; i < 5; i++) { - EXPECT_EQ(i, test_map.find(kKeys[i])->second->data()); - } -} - -// Test insertion of Unique Ptr kKeys and Payload -TEST_F(MapTest, EmplaceAndFindWithUniquePtrKey) { - Map, Payload, StringLess> test_map; - for (int i = 0; i < 5; i++) { - test_map.emplace(CopyString(kKeys[i]), Payload(i)); - } - for (int i = 0; i < 5; i++) { - EXPECT_EQ(i, test_map.find(CopyString(kKeys[i]))->second.data()); - } -} - -// Test insertion of Payload -TEST_F(MapTest, InsertAndFind) { - Map test_map; - for (int i = 0; i < 5; i++) { - test_map.insert(MakePair(kKeys[i], Payload(i))); - } - for (int i = 0; i < 5; i++) { - EXPECT_EQ(i, test_map.find(kKeys[i])->second.data()); - } -} - -// Test insertion of Payload Unique Ptrs -TEST_F(MapTest, InsertAndFindWithUniquePtrValue) { - Map, StringLess> test_map; - for (int i = 0; i < 5; i++) { - test_map.insert(MakePair(kKeys[i], MakeUnique(i))); - } - for (int i = 0; i < 5; i++) { - EXPECT_EQ(i, test_map.find(kKeys[i])->second->data()); - } -} - -// Test insertion of Unique Ptr kKeys and Payload -TEST_F(MapTest, InsertAndFindWithUniquePtrKey) { - Map, Payload, StringLess> test_map; - for (int i = 0; i < 5; i++) { - test_map.insert(MakePair(CopyString(kKeys[i]), Payload(i))); - } - for (int i = 0; i < 5; i++) { - EXPECT_EQ(i, test_map.find(CopyString(kKeys[i]))->second.data()); - } -} - -// Test bracket operators -TEST_F(MapTest, BracketOperator) { - Map test_map; - for (int i = 0; i < 5; i++) { - test_map[kKeys[i]] = Payload(i); - } - for (int i = 0; i < 5; i++) { - EXPECT_EQ(i, test_map[kKeys[i]].data()); - } -} - -// Test bracket operators with unique pointer to payload -TEST_F(MapTest, BracketOperatorWithUniquePtrValue) { - Map, StringLess> test_map; - for (int i = 0; i < 5; i++) { - test_map[kKeys[i]] = MakeUnique(i); - } - for (int i = 0; i < 5; i++) { - EXPECT_EQ(i, test_map[kKeys[i]]->data()); - } -} - -// Test bracket operators with unique pointer to payload -TEST_F(MapTest, BracketOperatorWithUniquePtrKey) { - Map, Payload, StringLess> test_map; - for (int i = 0; i < 5; i++) { - test_map[CopyString(kKeys[i])] = Payload(i); - } - for (int i = 0; i < 5; i++) { - EXPECT_EQ(i, test_map[CopyString(kKeys[i])].data()); - } -} - -// Test removal of a single value -TEST_F(MapTest, Erase) { - Map test_map; - for (int i = 0; i < 5; i++) { - test_map.emplace(kKeys[i], Payload(i)); - } - EXPECT_EQ(test_map.size(), 5UL); - EXPECT_EQ(test_map.erase(kKeys[3]), 1UL); // Remove "hij" - for (int i = 0; i < 5; i++) { - if (i == 3) { // "hij" should not be present - EXPECT_TRUE(test_map.find(kKeys[i]) == test_map.end()); - } else { - EXPECT_EQ(i, test_map.find(kKeys[i])->second.data()); - } - } - EXPECT_EQ(test_map.size(), 4UL); -} - -// Test removal of a single value with unique ptr to payload -TEST_F(MapTest, EraseWithUniquePtrValue) { - Map, StringLess> test_map; - for (int i = 0; i < 5; i++) { - test_map.emplace(kKeys[i], MakeUnique(i)); - } - EXPECT_EQ(test_map.size(), 5UL); - test_map.erase(kKeys[3]); // Remove "hij" - for (int i = 0; i < 5; i++) { - if (i == 3) { // "hij" should not be present - EXPECT_TRUE(test_map.find(kKeys[i]) == test_map.end()); - } else { - EXPECT_EQ(i, test_map.find(kKeys[i])->second->data()); - } - } - EXPECT_EQ(test_map.size(), 4UL); -} - -// Test removal of a single value -TEST_F(MapTest, EraseWithUniquePtrKey) { - Map, Payload, StringLess> test_map; - for (int i = 0; i < 5; i++) { - test_map.emplace(CopyString(kKeys[i]), Payload(i)); - } - EXPECT_EQ(test_map.size(), 5UL); - test_map.erase(CopyString(kKeys[3])); // Remove "hij" - for (int i = 0; i < 5; i++) { - if (i == 3) { // "hij" should not be present - EXPECT_TRUE(test_map.find(CopyString(kKeys[i])) == test_map.end()); - } else { - EXPECT_EQ(i, test_map.find(CopyString(kKeys[i]))->second.data()); - } - } - EXPECT_EQ(test_map.size(), 4UL); -} - -// Test clear -TEST_F(MapTest, SizeAndClear) { - Map test_map; - for (int i = 0; i < 5; i++) { - test_map.emplace(kKeys[i], Payload(i)); - } - EXPECT_EQ(test_map.size(), 5UL); - EXPECT_FALSE(test_map.empty()); - test_map.clear(); - EXPECT_EQ(test_map.size(), 0UL); - EXPECT_TRUE(test_map.empty()); -} - -// Test clear with unique ptr payload -TEST_F(MapTest, SizeAndClearWithUniquePtrValue) { - Map, StringLess> test_map; - for (int i = 0; i < 5; i++) { - test_map.emplace(kKeys[i], MakeUnique(i)); - } - EXPECT_EQ(test_map.size(), 5UL); - EXPECT_FALSE(test_map.empty()); - test_map.clear(); - EXPECT_EQ(test_map.size(), 0UL); - EXPECT_TRUE(test_map.empty()); -} - -// Test clear with unique ptr char key -TEST_F(MapTest, SizeAndClearWithUniquePtrKey) { - Map, Payload, StringLess> test_map; - for (int i = 0; i < 5; i++) { - test_map.emplace(CopyString(kKeys[i]), Payload(i)); - } - EXPECT_EQ(test_map.size(), 5UL); - EXPECT_FALSE(test_map.empty()); - test_map.clear(); - EXPECT_EQ(test_map.size(), 0UL); - EXPECT_TRUE(test_map.empty()); -} - -// Test correction of Left-Left Tree imbalance -TEST_F(MapTest, MapLL) { - Map test_map; - for (int i = 2; i >= 0; i--) { - test_map.emplace(kKeys[i], Payload(i)); - } - EXPECT_EQ(strcmp(Root(&test_map)->pair.first, kKeys[1]), 0); - EXPECT_EQ(strcmp(Root(&test_map)->left->pair.first, kKeys[0]), 0); - EXPECT_EQ(strcmp(Root(&test_map)->right->pair.first, kKeys[2]), 0); -} - -// Test correction of Left-Right tree imbalance -TEST_F(MapTest, MapLR) { - Map test_map; - int insertion_key_index[] = {2, 0, 1}; - for (int i = 0; i < 3; i++) { - int key_index = insertion_key_index[i]; - test_map.emplace(kKeys[key_index], Payload(key_index)); - } - EXPECT_EQ(strcmp(Root(&test_map)->pair.first, kKeys[1]), 0); - EXPECT_EQ(strcmp(Root(&test_map)->left->pair.first, kKeys[0]), 0); - EXPECT_EQ(strcmp(Root(&test_map)->right->pair.first, kKeys[2]), 0); -} - -// Test correction of Right-Left tree imbalance -TEST_F(MapTest, MapRL) { - Map test_map; - int insertion_key_index[] = {0, 2, 1}; - for (int i = 0; i < 3; i++) { - int key_index = insertion_key_index[i]; - test_map.emplace(kKeys[key_index], Payload(key_index)); - } - EXPECT_EQ(strcmp(Root(&test_map)->pair.first, kKeys[1]), 0); - EXPECT_EQ(strcmp(Root(&test_map)->left->pair.first, kKeys[0]), 0); - EXPECT_EQ(strcmp(Root(&test_map)->right->pair.first, kKeys[2]), 0); -} - -// Test correction of Right-Right tree imbalance -TEST_F(MapTest, MapRR) { - Map test_map; - for (int i = 0; i < 5; i++) { - test_map.emplace(kKeys[i], Payload(i)); - } - EXPECT_EQ(strcmp(Root(&test_map)->pair.first, kKeys[1]), 0); - EXPECT_EQ(strcmp(Root(&test_map)->left->pair.first, kKeys[0]), 0); - EXPECT_EQ(strcmp(Root(&test_map)->right->pair.first, kKeys[3]), 0); - EXPECT_EQ(strcmp(Root(&test_map)->right->left->pair.first, kKeys[2]), 0); - EXPECT_EQ(strcmp(Root(&test_map)->right->right->pair.first, kKeys[4]), 0); -} - -// Test correction after random insertion -TEST_F(MapTest, MapRandomInsertions) { - Map test_map; - int insertion_key_index[] = {1, 4, 3, 0, 2}; - for (int i = 0; i < 5; i++) { - int key_index = insertion_key_index[i]; - test_map.emplace(kKeys[key_index], Payload(key_index)); - } - EXPECT_EQ(strcmp(Root(&test_map)->pair.first, kKeys[3]), 0); - EXPECT_EQ(strcmp(Root(&test_map)->left->pair.first, kKeys[1]), 0); - EXPECT_EQ(strcmp(Root(&test_map)->right->pair.first, kKeys[4]), 0); - EXPECT_EQ(strcmp(Root(&test_map)->left->right->pair.first, kKeys[2]), 0); - EXPECT_EQ(strcmp(Root(&test_map)->left->left->pair.first, kKeys[0]), 0); -} - -// Test Map iterator -TEST_F(MapTest, Iteration) { - Map test_map; - for (int i = 4; i >= 0; --i) { - test_map.emplace(kKeys[i], Payload(i)); - } - auto it = test_map.begin(); - for (int i = 0; i < 5; ++i) { - ASSERT_NE(it, test_map.end()); - EXPECT_STREQ(kKeys[i], it->first); - EXPECT_EQ(i, it->second.data()); - ++it; - } - EXPECT_EQ(it, test_map.end()); -} - -// Test Map iterator with unique ptr payload -TEST_F(MapTest, IterationWithUniquePtrValue) { - Map, StringLess> test_map; - for (int i = 4; i >= 0; --i) { - test_map.emplace(kKeys[i], MakeUnique(i)); - } - auto it = test_map.begin(); - for (int i = 0; i < 5; ++i) { - ASSERT_NE(it, test_map.end()); - EXPECT_STREQ(kKeys[i], it->first); - EXPECT_EQ(i, it->second->data()); - ++it; - } - EXPECT_EQ(it, test_map.end()); -} - -// Test Map iterator with unique ptr to char key -TEST_F(MapTest, IterationWithUniquePtrKey) { - Map, Payload, StringLess> test_map; - for (int i = 4; i >= 0; --i) { - test_map.emplace(CopyString(kKeys[i]), Payload(i)); - } - auto it = test_map.begin(); - for (int i = 0; i < 5; ++i) { - ASSERT_NE(it, test_map.end()); - EXPECT_STREQ(kKeys[i], it->first.get()); - EXPECT_EQ(i, it->second.data()); - ++it; - } - EXPECT_EQ(it, test_map.end()); -} - -// Test removing entries while iterating the map -TEST_F(MapTest, EraseUsingIterator) { - Map test_map; - for (int i = 0; i < 5; i++) { - test_map.emplace(kKeys[i], Payload(i)); - } - int count = 0; - for (auto iter = test_map.begin(); iter != test_map.end();) { - EXPECT_EQ(iter->second.data(), count); - if (count % 2 == 1) { - iter = test_map.erase(iter); - } else { - ++iter; - } - ++count; - } - EXPECT_EQ(count, 5); - auto it = test_map.begin(); - for (int i = 0; i < 5; ++i) { - if (i % 2 == 0) { - EXPECT_STREQ(kKeys[i], it->first); - EXPECT_EQ(i, it->second.data()); - ++it; - } - } - EXPECT_EQ(it, test_map.end()); -} - -// Random ops on a Map with Integer key of Payload value, -// tests default comparator -TEST_F(MapTest, RandomOpsWithIntKey) { - Map test_map; - for (int i = 0; i < 5; i++) { - test_map.emplace(i, Payload(i)); - } - for (int i = 0; i < 5; i++) { - EXPECT_EQ(i, test_map.find(i)->second.data()); - } - for (int i = 0; i < 5; i++) { - test_map[i] = Payload(i + 10); - } - for (int i = 0; i < 5; i++) { - EXPECT_EQ(i + 10, test_map[i].data()); - } - EXPECT_EQ(test_map.erase(3), 1UL); - EXPECT_TRUE(test_map.find(3) == test_map.end()); - EXPECT_FALSE(test_map.empty()); - EXPECT_EQ(test_map.size(), 4UL); - test_map.clear(); - EXPECT_EQ(test_map.size(), 0UL); - EXPECT_TRUE(test_map.empty()); -} - -// Tests lower_bound(). -TEST_F(MapTest, LowerBound) { - Map test_map; - for (int i = 0; i < 10; i += 2) { - test_map.emplace(i, Payload(i)); - } - auto it = test_map.lower_bound(-1); - EXPECT_EQ(it, test_map.begin()); - it = test_map.lower_bound(0); - EXPECT_EQ(it, test_map.begin()); - it = test_map.lower_bound(2); - EXPECT_EQ(it->first, 2); - it = test_map.lower_bound(3); - EXPECT_EQ(it->first, 4); - it = test_map.lower_bound(9); - EXPECT_EQ(it, test_map.end()); -} - -// Test move ctor -TEST_F(MapTest, MoveCtor) { - Map test_map; - for (int i = 0; i < 5; i++) { - test_map.emplace(kKeys[i], Payload(i)); - } - Map test_map2 = std::move(test_map); - for (int i = 0; i < 5; i++) { - EXPECT_EQ(test_map.end(), test_map.find(kKeys[i])); - EXPECT_EQ(i, test_map2.find(kKeys[i])->second.data()); - } -} - -// Test move assignment -TEST_F(MapTest, MoveAssignment) { - Map test_map; - for (int i = 0; i < 5; i++) { - test_map.emplace(kKeys[i], Payload(i)); - } - Map test_map2; - test_map2.emplace("xxx", Payload(123)); - test_map2 = std::move(test_map); - for (int i = 0; i < 5; i++) { - EXPECT_EQ(test_map.end(), test_map.find(kKeys[i])); - EXPECT_EQ(i, test_map2.find(kKeys[i])->second.data()); - } - EXPECT_EQ(test_map2.end(), test_map2.find("xxx")); -} - -// Test copy ctor -TEST_F(MapTest, CopyCtor) { - Map test_map; - for (int i = 0; i < 5; i++) { - test_map.emplace(kKeys[i], Payload(i)); - } - Map test_map2 = test_map; - for (int i = 0; i < 5; i++) { - EXPECT_EQ(i, test_map.find(kKeys[i])->second.data()); - EXPECT_EQ(i, test_map2.find(kKeys[i])->second.data()); - } -} - -// Test copy assignment -TEST_F(MapTest, CopyAssignment) { - Map test_map; - for (int i = 0; i < 5; i++) { - test_map.emplace(kKeys[i], Payload(i)); - } - Map test_map2; - test_map2.emplace("xxx", Payload(123)); - test_map2 = test_map; - for (int i = 0; i < 5; i++) { - EXPECT_EQ(i, test_map.find(kKeys[i])->second.data()); - EXPECT_EQ(i, test_map2.find(kKeys[i])->second.data()); - } - EXPECT_EQ(test_map2.end(), test_map2.find("xxx")); -} - -#endif - -} // namespace testing -} // namespace grpc_core - -int main(int argc, char** argv) { - grpc::testing::TestEnvironment env(argc, argv); - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/test/cpp/qps/interarrival.h b/test/cpp/qps/interarrival.h index ce4bf3d30c9..61a6d75a3c8 100644 --- a/test/cpp/qps/interarrival.h +++ b/test/cpp/qps/interarrival.h @@ -81,7 +81,6 @@ class InterarrivalTimer { for (int i = 0; i < entries; i++) { random_table_.push_back( static_cast(1e9 * r.transform(rando(generator)))); - ; } // Now set up the thread positions for (int i = 0; i < threads; i++) { diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 5f62f39427f..fd709c70e84 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -1101,7 +1101,6 @@ src/core/lib/gpr/tls_msvc.h \ src/core/lib/gpr/tls_pthread.h \ src/core/lib/gpr/tmpfile.h \ src/core/lib/gpr/useful.h \ -src/core/lib/gprpp/abstract.h \ src/core/lib/gprpp/arena.h \ src/core/lib/gprpp/atomic.h \ src/core/lib/gprpp/debug_location.h \ diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 249ec2420dd..eba49015f19 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -1232,7 +1232,6 @@ src/core/lib/gpr/tmpfile_windows.cc \ src/core/lib/gpr/useful.h \ src/core/lib/gpr/wrap_memcpy.cc \ src/core/lib/gprpp/README.md \ -src/core/lib/gprpp/abstract.h \ src/core/lib/gprpp/arena.cc \ src/core/lib/gprpp/arena.h \ src/core/lib/gprpp/atomic.h \ diff --git a/tools/internal_ci/linux/grpc_bazel_build_in_docker.sh b/tools/internal_ci/linux/grpc_bazel_build_in_docker.sh index 8487ec49bbd..24598f43f02 100755 --- a/tools/internal_ci/linux/grpc_bazel_build_in_docker.sh +++ b/tools/internal_ci/linux/grpc_bazel_build_in_docker.sh @@ -25,4 +25,3 @@ git clone /var/local/jenkins/grpc /var/local/git/grpc ${name}') cd /var/local/git/grpc bazel build --spawn_strategy=standalone --genrule_strategy=standalone :all test/... examples/... -bazel build --spawn_strategy=standalone --genrule_strategy=standalone --define=GRPC_USE_CPP_STD_LIB=1 :grpc diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json index b4b3822bde5..54d6594704d 100644 --- a/tools/run_tests/generated/tests.json +++ b/tools/run_tests/generated/tests.json @@ -4739,30 +4739,6 @@ ], "uses_polling": true }, - { - "args": [], - "benchmark": false, - "ci_platforms": [ - "linux", - "mac", - "posix", - "windows" - ], - "cpu_cost": 1.0, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "gtest": true, - "language": "c++", - "name": "grpc_core_map_test", - "platforms": [ - "linux", - "mac", - "posix", - "windows" - ], - "uses_polling": false - }, { "args": [], "benchmark": false,