Replace Map with std::map

pull/20350/head
Esun Kim 5 years ago
parent 90e5ade73b
commit 2a8de59fb0
  1. 4
      src/core/ext/filters/client_channel/backend_metric.cc
  2. 12
      src/core/ext/filters/client_channel/client_channel.cc
  3. 4
      src/core/ext/filters/client_channel/lb_policy.h
  4. 4
      src/core/ext/filters/client_channel/lb_policy/xds/xds.cc
  5. 14
      src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.h
  6. 2
      src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h
  7. 6
      src/core/ext/filters/client_channel/subchannel.h
  8. 8
      src/core/lib/channel/channelz.h
  9. 2
      src/core/lib/channel/channelz_registry.h
  10. 3
      src/core/lib/gprpp/map.h
  11. 12
      src/core/lib/security/credentials/credentials.cc
  12. 6
      src/core/lib/security/credentials/credentials.h
  13. 11
      src/core/lib/transport/connectivity_state.h

@ -26,12 +26,12 @@ namespace grpc_core {
namespace {
template <typename EntryType>
Map<StringView, double, StringLess> ParseMap(
std::map<StringView, double, StringLess> 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<StringView, double, StringLess> result;
std::map<StringView, double, StringLess> result;
size_t size;
const auto* const* entries = entry_func(msg, &size);
for (size_t i = 0; i < size; ++i) {

@ -282,18 +282,18 @@ class ChannelData {
RefCountedPtr<ServiceConfig> saved_service_config_;
bool received_first_resolver_result_ = false;
// The number of SubchannelWrapper instances referencing a given Subchannel.
Map<Subchannel*, int> subchannel_refcount_map_;
std::map<Subchannel*, int> 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<SubchannelWrapper*, bool> subchannel_wrappers_;
std::map<SubchannelWrapper*, bool> 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<SubchannelWrapper>, RefCountedPtr<ConnectedSubchannel>,
RefCountedPtrLess<SubchannelWrapper>>
std::map<RefCountedPtr<SubchannelWrapper>, RefCountedPtr<ConnectedSubchannel>,
RefCountedPtrLess<SubchannelWrapper>>
pending_subchannel_updates_;
//
@ -314,7 +314,7 @@ class ChannelData {
// synchronously via grpc_channel_num_external_connectivity_watchers().
//
mutable Mutex external_watchers_mu_;
Map<grpc_closure*, ExternalConnectivityWatcher*> external_watchers_;
std::map<grpc_closure*, ExternalConnectivityWatcher*> 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<ConnectivityStateWatcherInterface*, WatcherWrapper*> watcher_map_;
std::map<ConnectivityStateWatcherInterface*, WatcherWrapper*> watcher_map_;
// To be accessed only in the control plane combiner.
RefCountedPtr<ConnectedSubchannel> connected_subchannel_;
// To be accessed only in the data plane mutex.

@ -90,11 +90,11 @@ class LoadBalancingPolicy : public InternallyRefCounted<LoadBalancingPolicy> {
/// 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<StringView, double, StringLess> request_cost;
std::map<StringView, double, StringLess> 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<StringView, double, StringLess> utilization;
std::map<StringView, double, StringLess> utilization;
};
/// Interface for accessing per-call state.

@ -576,8 +576,8 @@ class XdsLb : public LoadBalancingPolicy {
RefCountedPtr<XdsLb> xds_policy_;
Map<RefCountedPtr<XdsLocalityName>, OrphanablePtr<Locality>,
XdsLocalityName::Less>
std::map<RefCountedPtr<XdsLocalityName>, OrphanablePtr<Locality>,
XdsLocalityName::Less>
localities_;
const uint32_t priority_;
grpc_connectivity_state connectivity_state_ = GRPC_CHANNEL_IDLE;

@ -111,9 +111,9 @@ class XdsClientStats {
double total_metric_value_{0};
};
using LoadMetricMap = Map<UniquePtr<char>, LoadMetric, StringLess>;
using LoadMetricMap = std::map<UniquePtr<char>, LoadMetric, StringLess>;
using LoadMetricSnapshotMap =
Map<UniquePtr<char>, LoadMetric::Snapshot, StringLess>;
std::map<UniquePtr<char>, 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>, RefCountedPtr<LocalityStats>,
XdsLocalityName::Less>;
std::map<RefCountedPtr<XdsLocalityName>, RefCountedPtr<LocalityStats>,
XdsLocalityName::Less>;
using LocalityStatsSnapshotMap =
Map<RefCountedPtr<XdsLocalityName>, LocalityStats::Snapshot,
XdsLocalityName::Less>;
using DroppedRequestsMap = Map<UniquePtr<char>, uint64_t, StringLess>;
std::map<RefCountedPtr<XdsLocalityName>, LocalityStats::Snapshot,
XdsLocalityName::Less>;
using DroppedRequestsMap = std::map<UniquePtr<char>, uint64_t, StringLess>;
using DroppedRequestsSnapshotMap = DroppedRequestsMap;
struct Snapshot {

@ -57,7 +57,7 @@ class XdsPriorityListUpdate {
size_t size() const { return localities.size(); }
Map<RefCountedPtr<XdsLocalityName>, Locality, XdsLocalityName::Less>
std::map<RefCountedPtr<XdsLocalityName>, Locality, XdsLocalityName::Less>
localities;
};

@ -294,8 +294,8 @@ class Subchannel {
private:
// TODO(roth): This could be a set instead of a map if we had a set
// implementation.
Map<ConnectivityStateWatcherInterface*,
OrphanablePtr<ConnectivityStateWatcherInterface>>
std::map<ConnectivityStateWatcherInterface*,
OrphanablePtr<ConnectivityStateWatcherInterface>>
watchers_;
};
@ -328,7 +328,7 @@ class Subchannel {
private:
class HealthWatcher;
Map<const char*, OrphanablePtr<HealthWatcher>, StringLess> map_;
std::map<const char*, OrphanablePtr<HealthWatcher>, StringLess> map_;
};
class ConnectedSubchannelStateWatcher;

@ -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<intptr_t, bool> child_channels_;
Map<intptr_t, bool> child_subchannels_;
std::map<intptr_t, bool> child_channels_;
std::map<intptr_t, bool> 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<intptr_t, RefCountedPtr<SocketNode>> child_sockets_;
Map<intptr_t, RefCountedPtr<ListenSocketNode>> child_listen_sockets_;
std::map<intptr_t, RefCountedPtr<SocketNode>> child_sockets_;
std::map<intptr_t, RefCountedPtr<ListenSocketNode>> child_listen_sockets_;
};
// Handles channelz bookkeeping for sockets

@ -87,7 +87,7 @@ class ChannelzRegistry {
// protects members
Mutex mu_;
Map<intptr_t, BaseNode*> node_map_;
std::map<intptr_t, BaseNode*> node_map_;
intptr_t uuid_generator_ = 0;
};

@ -59,9 +59,6 @@ struct RefCountedPtrLess {
}
};
template <class Key, class T, class Compare = std::less<Key>>
using Map = std::map<Key, T, Compare>;
} // namespace grpc_core
#endif /* GRPC_CORE_LIB_GPRPP_MAP_H */

@ -45,18 +45,18 @@ void grpc_channel_credentials_release(grpc_channel_credentials* creds) {
if (creds) creds->Unref();
}
static grpc_core::Map<grpc_core::UniquePtr<char>,
grpc_core::RefCountedPtr<grpc_channel_credentials>,
grpc_core::StringLess>* g_grpc_control_plane_creds;
static std::map<grpc_core::UniquePtr<char>,
grpc_core::RefCountedPtr<grpc_channel_credentials>,
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::UniquePtr<char>,
grpc_core::RefCountedPtr<grpc_channel_credentials>,
grpc_core::StringLess>>();
std::map<grpc_core::UniquePtr<char>,
grpc_core::RefCountedPtr<grpc_channel_credentials>,
grpc_core::StringLess>>();
}
void grpc_control_plane_credentials_init() {

@ -148,9 +148,9 @@ struct grpc_channel_credentials
private:
const char* type_;
grpc_core::Map<grpc_core::UniquePtr<char>,
grpc_core::RefCountedPtr<grpc_channel_credentials>,
grpc_core::StringLess>
std::map<grpc_core::UniquePtr<char>,
grpc_core::RefCountedPtr<grpc_channel_credentials>,
grpc_core::StringLess>
local_control_plane_creds_;
};

@ -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<grpc_connectivity_state> state_;
// TODO(roth): This could be a set instead of a map if we had a set
// implementation.
Map<ConnectivityStateWatcherInterface*,
OrphanablePtr<ConnectivityStateWatcherInterface>>
std::map<ConnectivityStateWatcherInterface*,
OrphanablePtr<ConnectivityStateWatcherInterface>>
watchers_;
};

Loading…
Cancel
Save