2020-07-30 16:28:56 +02:00
|
|
|
//
|
2022-01-01 01:35:39 +01:00
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
|
2020-07-30 16:28:56 +02:00
|
|
|
//
|
|
|
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
|
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
//
|
|
|
|
#pragma once
|
2020-07-30 21:59:23 +02:00
|
|
|
|
2020-07-30 16:28:56 +02:00
|
|
|
#include "td/telegram/net/NetQueryCounter.h"
|
|
|
|
|
2020-07-30 21:59:23 +02:00
|
|
|
#include "td/utils/common.h"
|
2020-07-30 16:28:56 +02:00
|
|
|
#include "td/utils/TsList.h"
|
|
|
|
|
|
|
|
#include <atomic>
|
|
|
|
|
|
|
|
namespace td {
|
2020-07-30 21:59:23 +02:00
|
|
|
|
2020-07-30 16:28:56 +02:00
|
|
|
struct NetQueryDebug {
|
|
|
|
double start_timestamp_ = 0;
|
2021-09-03 11:27:59 +02:00
|
|
|
int64 my_id_ = 0;
|
2020-07-30 16:28:56 +02:00
|
|
|
int32 resend_count_ = 0;
|
|
|
|
string state_ = "empty";
|
|
|
|
double state_timestamp_ = 0;
|
|
|
|
int32 state_change_count_ = 0;
|
|
|
|
int32 send_failed_count_ = 0;
|
|
|
|
int ack_state_ = 0;
|
|
|
|
bool unknown_state_ = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
class NetQueryStats {
|
|
|
|
public:
|
|
|
|
NetQueryCounter register_query(TsListNode<NetQueryDebug> *query) {
|
|
|
|
if (use_list_.load(std::memory_order_relaxed)) {
|
|
|
|
list_.put(query);
|
|
|
|
}
|
|
|
|
return NetQueryCounter(&count_);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64 get_count() const;
|
2020-07-30 21:59:23 +02:00
|
|
|
|
2020-07-30 16:28:56 +02:00
|
|
|
void dump_pending_network_queries();
|
|
|
|
|
|
|
|
private:
|
2020-10-13 01:30:40 +02:00
|
|
|
NetQueryCounter::Counter count_{0};
|
2020-07-30 16:28:56 +02:00
|
|
|
std::atomic<bool> use_list_{true};
|
|
|
|
TsList<NetQueryDebug> list_;
|
|
|
|
};
|
2020-07-30 21:59:23 +02:00
|
|
|
|
2020-07-30 16:28:56 +02:00
|
|
|
} // namespace td
|