// These methods are only for tests. const Connection* FindNextPingableConnection() override; void MarkConnectionPinged(const Connection* conn) override;
private: // A transport channel is weak if the current best connection is either // not receiving or not writable, or if there is no best connection at all. bool weak() const { return !selected_connection_ || selected_connection_->weak();
}
const Connection* FindOldestConnectionNeedingTriggeredCheck(Timestamp now); // Between `conn1` and `conn2`, this function returns the one which should // be pinged first. const Connection* MorePingable(const Connection* conn1, const Connection* conn2); // Select the connection which is Relay/Relay. If both of them are, // UDP relay protocol takes precedence. const Connection* MostLikelyToWork(const Connection* conn1, const Connection* conn2); // Compare the last_ping_sent time and return the one least recently pinged. const Connection* LeastRecentlyPinged(const Connection* conn1, const Connection* conn2);
bool IsPingable(const Connection* conn, Timestamp now) const; bool IsBackupConnection(const Connection* conn) const; // Whether a writable connection is past its ping interval and needs to be // pinged again. bool WritableConnectionPastPingInterval(const Connection* conn,
Timestamp now) const;
TimeDelta CalculateActiveWritablePingInterval(const Connection* conn,
Timestamp now) const;
int CompareCandidatePairNetworks( const Connection* a, const Connection* b,
std::optional<AdapterType> network_preference) const;
// The methods below return a positive value if `a` is preferable to `b`, // a negative value if `b` is preferable, and 0 if they're equally preferable. // If `receiving_unchanged_threshold` is set, then when `b` is receiving and // `a` is not, returns a negative value only if `b` has been in receiving // state and `a` has been in not receiving state since // `receiving_unchanged_threshold` and sets // `missed_receiving_unchanged_threshold` to true otherwise. int CompareConnectionStates( const Connection* a, const Connection* b,
std::optional<int64_t> receiving_unchanged_threshold, bool* missed_receiving_unchanged_threshold) const; int CompareConnectionCandidates(const Connection* a, const Connection* b) const; // Compares two connections based on the connection states // (writable/receiving/connected), nomination states, last data received time, // and static preferences. Does not include latency. Used by both sorting // and ShouldSwitchSelectedConnection(). // Returns a positive value if `a` is better than `b`. int CompareConnections(const Connection* a, const Connection* b,
std::optional<int64_t> receiving_unchanged_threshold, bool* missed_receiving_unchanged_threshold) const;
// `connections_` is a sorted list with the first one always be the // `selected_connection_` when it's not nullptr. The combination of // `pinged_connections_` and `unpinged_connections_` has the same // connections as `connections_`. These 2 sets maintain whether a // connection should be pinged next or not. const Connection* selected_connection_ = nullptr;
std::vector<const Connection*> connections_;
std::set<const Connection*> pinged_connections_;
std::set<const Connection*> unpinged_connections_;
// Timestamp for when we got the first selectable connection.
std::optional<Timestamp> initial_select_timestamp_;
};
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.