bool ConnPoolImplBase::shouldConnect(size_t pending_streams, size_t active_streams,
                                     int64_t connecting_and_connected_capacity,
                                     float preconnect_ratio, bool anticipate_incoming_stream) {
  // This is set to true any time global preconnect is being calculated.
  // ClusterManagerImpl::maybePreconnect is called directly before a stream is created, so the
  // stream must be anticipated.
  //
  // Also without this, we would never pre-establish a connection as the first
  // connection in a pool because pending/active streams could both be 0.
  int anticipated_streams = anticipate_incoming_stream ? 1 : 0;

  // The number of streams we want to be provisioned for is the number of
  // pending, active, and anticipated streams times the preconnect ratio.
  // The number of streams we are (theoretically) provisioned for is the
  // connecting stream capacity plus the number of active streams.
  //
  // If preconnect ratio is not set, it defaults to 1, and this simplifies to the
  // legacy value of pending_streams_.size() > connecting_stream_capacity_
  return (pending_streams + active_streams + anticipated_streams) * preconnect_ratio >
         connecting_and_connected_capacity + active_streams;
}
bool ConnPoolImplBase::shouldConnect(size_t pending_streams, size_t active_streams,
                                     int64_t connecting_and_connected_capacity,
                                     float preconnect_ratio, bool anticipate_incoming_stream) {
   
   
   
   
   
   
  int anticipated_streams = anticipate_incoming_stream ? 1 : 0;

   
   
   
   
   
   
   
  return (pending_streams + active_streams + anticipated_streams) * preconnect_ratio >
         connecting_and_connected_capacity + active_streams;
}