From 5dd42ab4bb15130d46a36df6c06da3d72a047ca2 Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Wed, 4 Apr 2018 07:40:19 -0700 Subject: [PATCH] clang-format --- .../lb_policy/pick_first/pick_first.cc | 19 +++-- .../lb_policy/round_robin/round_robin.cc | 58 ++++++++------- .../lb_policy/subchannel_list.h | 71 +++++++++---------- 3 files changed, 69 insertions(+), 79 deletions(-) diff --git a/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc b/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc index 5fd4cade9ef..7d66d0acd9a 100644 --- a/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +++ b/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc @@ -73,8 +73,8 @@ class PickFirst : public LoadBalancingPolicy { const grpc_lb_address& address, grpc_subchannel* subchannel, grpc_combiner* combiner) - : SubchannelData(subchannel_list, user_data_vtable, address, - subchannel, combiner) {} + : SubchannelData(subchannel_list, user_data_vtable, address, subchannel, + combiner) {} void ProcessConnectivityChangeLocked(grpc_error* error) override; }; @@ -83,11 +83,11 @@ class PickFirst : public LoadBalancingPolicy { : public SubchannelList { public: - PickFirstSubchannelList( - PickFirst* policy, TraceFlag* tracer, - const grpc_lb_addresses* addresses, grpc_combiner* combiner, - grpc_client_channel_factory* client_channel_factory, - const grpc_channel_args& args) + PickFirstSubchannelList(PickFirst* policy, TraceFlag* tracer, + const grpc_lb_addresses* addresses, + grpc_combiner* combiner, + grpc_client_channel_factory* client_channel_factory, + const grpc_channel_args& args) : SubchannelList(policy, tracer, addresses, combiner, client_channel_factory, args) {} @@ -430,9 +430,8 @@ void PickFirst::PickFirstSubchannelData::ProcessConnectivityChangeLocked( "sd->subchannel_list->shutting_down=%d error=%s", p, subchannel(), Index(), subchannel_list()->num_subchannels(), subchannel_list(), - grpc_connectivity_state_name(connectivity_state()), - p->shutdown_, subchannel_list()->shutting_down(), - grpc_error_string(error)); + grpc_connectivity_state_name(connectivity_state()), p->shutdown_, + subchannel_list()->shutting_down(), grpc_error_string(error)); } // If the policy is shutting down, unref and return. if (p->shutdown_) { diff --git a/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc b/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc index 06ca89c7231..db093c8f53e 100644 --- a/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +++ b/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc @@ -91,12 +91,12 @@ class RoundRobin : public LoadBalancingPolicy { const grpc_lb_address& address, grpc_subchannel* subchannel, grpc_combiner* combiner) - : SubchannelData(subchannel_list, user_data_vtable, address, - subchannel, combiner), + : SubchannelData(subchannel_list, user_data_vtable, address, subchannel, + combiner), user_data_vtable_(user_data_vtable), user_data_(user_data_vtable_ != nullptr - ? user_data_vtable_->copy(address.user_data) - : nullptr) {} + ? user_data_vtable_->copy(address.user_data) + : nullptr) {} void UnrefSubchannelLocked(const char* reason) override { SubchannelData::UnrefSubchannelLocked(reason); @@ -255,8 +255,8 @@ size_t RoundRobin::GetNextReadySubchannelIndexLocked() { gpr_log(GPR_DEBUG, "[RR %p] found next ready subchannel (%p) at index %" PRIuPTR " of subchannel_list %p", - this, subchannel_list_->subchannel(index)->subchannel(), - index, subchannel_list_.get()); + this, subchannel_list_->subchannel(index)->subchannel(), index, + subchannel_list_.get()); } return index; } @@ -272,13 +272,13 @@ void RoundRobin::UpdateLastReadySubchannelIndexLocked(size_t last_ready_index) { GPR_ASSERT(last_ready_index < subchannel_list_->num_subchannels()); last_ready_subchannel_index_ = last_ready_index; if (grpc_lb_round_robin_trace.enabled()) { - gpr_log(GPR_DEBUG, - "[RR %p] setting last_ready_subchannel_index=%" PRIuPTR - " (SC %p, CSC %p)", - this, last_ready_index, - subchannel_list_->subchannel(last_ready_index)->subchannel(), - subchannel_list_->subchannel(last_ready_index) - ->connected_subchannel()); + gpr_log( + GPR_DEBUG, + "[RR %p] setting last_ready_subchannel_index=%" PRIuPTR + " (SC %p, CSC %p)", + this, last_ready_index, + subchannel_list_->subchannel(last_ready_index)->subchannel(), + subchannel_list_->subchannel(last_ready_index)->connected_subchannel()); } } @@ -382,12 +382,11 @@ bool RoundRobin::DoPickLocked(PickState* pick) { *pick->user_data = sd->user_data(); } if (grpc_lb_round_robin_trace.enabled()) { - gpr_log( - GPR_DEBUG, - "[RR %p] Picked target <-- Subchannel %p (connected %p) (sl %p, " - "index %" PRIuPTR ")", - this, sd->subchannel(), pick->connected_subchannel.get(), - sd->subchannel_list(), next_ready_index); + gpr_log(GPR_DEBUG, + "[RR %p] Picked target <-- Subchannel %p (connected %p) (sl %p, " + "index %" PRIuPTR ")", + this, sd->subchannel(), pick->connected_subchannel.get(), + sd->subchannel_list(), next_ready_index); } /* only advance the last picked pointer if the selection was used */ UpdateLastReadySubchannelIndexLocked(next_ready_index); @@ -508,8 +507,8 @@ void RoundRobin::RoundRobinSubchannelList::UpdateStateCountersLocked( // Sets the RR policy's connectivity state based on the current // subchannel list. -void -RoundRobin::RoundRobinSubchannelList::MaybeUpdateConnectivityStateLocked() { +void RoundRobin::RoundRobinSubchannelList:: + MaybeUpdateConnectivityStateLocked() { RoundRobin* p = static_cast(policy()); // Only set connectivity state if this is the current subchannel list. if (p->subchannel_list_ != this) return; @@ -586,14 +585,14 @@ void RoundRobin::RoundRobinSubchannelData::ProcessConnectivityChangeLocked( gpr_log( GPR_DEBUG, "[RR %p] connectivity changed for subchannel %p, subchannel_list %p " - "(index %" PRIuPTR " of %" PRIuPTR "): prev_state=%s new_state=%s " + "(index %" PRIuPTR " of %" PRIuPTR + "): prev_state=%s new_state=%s " "p->shutdown=%d sd->subchannel_list->shutting_down=%d error=%s", p, subchannel(), subchannel_list(), Index(), subchannel_list()->num_subchannels(), grpc_connectivity_state_name(prev_connectivity_state_), - grpc_connectivity_state_name(connectivity_state()), - p->shutdown_, subchannel_list()->shutting_down(), - grpc_error_string(error)); + grpc_connectivity_state_name(connectivity_state()), p->shutdown_, + subchannel_list()->shutting_down(), grpc_error_string(error)); } GPR_ASSERT(subchannel() != nullptr); // If the subchannel list is shutting down, stop watching. @@ -633,9 +632,8 @@ void RoundRobin::RoundRobinSubchannelData::ProcessConnectivityChangeLocked( case GRPC_CHANNEL_IDLE:; // fallthrough } // Update state counters. - subchannel_list()->UpdateStateCountersLocked(prev_connectivity_state_, - connectivity_state(), - GRPC_ERROR_REF(error)); + subchannel_list()->UpdateStateCountersLocked( + prev_connectivity_state_, connectivity_state(), GRPC_ERROR_REF(error)); prev_connectivity_state_ = connectivity_state(); // If we've started watching, update overall state and renew notification. if (subchannel_list()->started_watching()) { @@ -694,8 +692,8 @@ void RoundRobin::UpdateLocked(const grpc_channel_args& args) { if (latest_pending_subchannel_list_ != nullptr) { if (grpc_lb_round_robin_trace.enabled()) { gpr_log(GPR_DEBUG, - "[RR %p] Shutting down previous pending subchannel list %p", - this, latest_pending_subchannel_list_.get()); + "[RR %p] Shutting down previous pending subchannel list %p", this, + latest_pending_subchannel_list_.get()); } latest_pending_subchannel_list_->ShutdownLocked("sl_outdated"); } 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 5f7810d801e..73d598e9f19 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 @@ -154,11 +154,10 @@ class SubchannelData { GRPC_ABSTRACT_BASE_CLASS protected: - SubchannelData( - SubchannelListType* subchannel_list, - const grpc_lb_user_data_vtable* user_data_vtable, - const grpc_lb_address& address, grpc_subchannel* subchannel, - grpc_combiner* combiner); + SubchannelData(SubchannelListType* subchannel_list, + const grpc_lb_user_data_vtable* user_data_vtable, + const grpc_lb_address& address, grpc_subchannel* subchannel, + grpc_combiner* combiner); virtual ~SubchannelData(); @@ -195,8 +194,7 @@ class SubchannelData { // A list of subchannels. template -class SubchannelList - : public RefCountedWithTracing { +class SubchannelList : public RefCountedWithTracing { public: typedef InlinedVector SubchannelVector; @@ -278,17 +276,16 @@ SubchannelData::~SubchannelData() { } template -void SubchannelData::UnrefSubchannelLocked( - const char* reason) { +void SubchannelData:: + UnrefSubchannelLocked(const char* reason) { if (subchannel_ != nullptr) { if (subchannel_list_->tracer()->enabled()) { gpr_log(GPR_DEBUG, "[%s %p] subchannel list %p index %" PRIuPTR " of %" PRIuPTR " (subchannel %p): unreffing subchannel", subchannel_list_->tracer()->name(), subchannel_list_->policy(), - subchannel_list_, Index(), - subchannel_list_->num_subchannels(), subchannel_); + subchannel_list_, Index(), subchannel_list_->num_subchannels(), + subchannel_); } GRPC_SUBCHANNEL_UNREF(subchannel_, reason); subchannel_ = nullptr; @@ -300,21 +297,19 @@ template void SubchannelData::StartConnectivityWatchLocked() { if (subchannel_list_->tracer()->enabled()) { - gpr_log( - GPR_DEBUG, - "[%s %p] subchannel list %p index %" PRIuPTR " of %" PRIuPTR - " (subchannel %p): requesting connectivity change " - "notification (from %s)", - subchannel_list_->tracer()->name(), subchannel_list_->policy(), - subchannel_list_, Index(), - subchannel_list_->num_subchannels(), subchannel_, - grpc_connectivity_state_name(pending_connectivity_state_unsafe_)); + gpr_log(GPR_DEBUG, + "[%s %p] subchannel list %p index %" PRIuPTR " of %" PRIuPTR + " (subchannel %p): requesting connectivity change " + "notification (from %s)", + subchannel_list_->tracer()->name(), subchannel_list_->policy(), + subchannel_list_, Index(), subchannel_list_->num_subchannels(), + subchannel_, + grpc_connectivity_state_name(pending_connectivity_state_unsafe_)); } connectivity_notification_pending_ = true; grpc_subchannel_notify_on_state_change( subchannel_, subchannel_list_->policy()->interested_parties(), - &pending_connectivity_state_unsafe_, - &connectivity_changed_closure_); + &pending_connectivity_state_unsafe_, &connectivity_changed_closure_); } template @@ -325,33 +320,31 @@ void SubchannelDatatracer()->name(), subchannel_list_->policy(), - subchannel_list_, Index(), - subchannel_list_->num_subchannels(), subchannel_); + subchannel_list_, Index(), subchannel_list_->num_subchannels(), + subchannel_); } GPR_ASSERT(connectivity_notification_pending_); connectivity_notification_pending_ = false; } template -void SubchannelData::CancelConnectivityWatchLocked( - const char* reason) { +void SubchannelData:: + CancelConnectivityWatchLocked(const char* reason) { if (subchannel_list_->tracer()->enabled()) { gpr_log(GPR_DEBUG, "[%s %p] subchannel list %p index %" PRIuPTR " of %" PRIuPTR " (subchannel %p): canceling connectivity watch (%s)", subchannel_list_->tracer()->name(), subchannel_list_->policy(), - subchannel_list_, Index(), - subchannel_list_->num_subchannels(), subchannel_, reason); + subchannel_list_, Index(), subchannel_list_->num_subchannels(), + subchannel_, reason); } grpc_subchannel_notify_on_state_change(subchannel_, nullptr, nullptr, &connectivity_changed_closure_); } template -void SubchannelData::OnConnectivityChangedLocked( - void* arg, grpc_error* error) { +void SubchannelData:: + OnConnectivityChangedLocked(void* arg, grpc_error* error) { SubchannelData* sd = static_cast(arg); // Now that we're inside the combiner, copy the pending connectivity // state (which was set by the connectivity state watcher) to @@ -365,8 +358,8 @@ void SubchannelData -void SubchannelData::ShutdownLocked(const char* reason) { +void SubchannelData::ShutdownLocked( + const char* reason) { // If there's a pending notification for this subchannel, cancel it; // the callback is responsible for unreffing the subchannel. // Otherwise, unref the subchannel directly. @@ -447,14 +440,14 @@ SubchannelList::SubchannelList( template SubchannelList::~SubchannelList() { if (tracer_->enabled()) { - gpr_log(GPR_DEBUG, "[%s %p] Destroying subchannel_list %p", - tracer_->name(), policy_, this); + gpr_log(GPR_DEBUG, "[%s %p] Destroying subchannel_list %p", tracer_->name(), + policy_, this); } } template -void SubchannelList::ShutdownLocked(const char* reason) { +void SubchannelList::ShutdownLocked( + const char* reason) { if (tracer_->enabled()) { gpr_log(GPR_DEBUG, "[%s %p] Shutting down subchannel_list %p (%s)", tracer_->name(), policy_, this, reason);