mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
optimistic out-msg-queue broadcast
This commit is contained in:
parent
6df6f182bf
commit
bf572f9599
24 changed files with 623 additions and 126 deletions
|
@ -19,6 +19,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "td/utils/StringBuilder.h"
|
||||
#include "td/utils/Status.h"
|
||||
|
||||
#include <functional>
|
||||
|
||||
|
@ -46,7 +47,7 @@ class Timer {
|
|||
|
||||
class PerfWarningTimer {
|
||||
public:
|
||||
explicit PerfWarningTimer(string name, double max_duration = 0.1, std::function<void(double)>&& callback = {});
|
||||
explicit PerfWarningTimer(string name, double max_duration = 0.1, std::function<void(double)> &&callback = {});
|
||||
PerfWarningTimer(const PerfWarningTimer &) = delete;
|
||||
PerfWarningTimer &operator=(const PerfWarningTimer &) = delete;
|
||||
PerfWarningTimer(PerfWarningTimer &&other);
|
||||
|
@ -80,4 +81,44 @@ class ThreadCpuTimer {
|
|||
bool is_paused_{false};
|
||||
};
|
||||
|
||||
class PerfLog;
|
||||
struct EmptyDeleter {
|
||||
template <class T>
|
||||
void operator()(T *) {
|
||||
}
|
||||
};
|
||||
class PerfLogAction {
|
||||
public:
|
||||
template <class T>
|
||||
double finish(const T &result);
|
||||
size_t i_{0};
|
||||
std::unique_ptr<PerfLog, EmptyDeleter> perf_log_;
|
||||
};
|
||||
|
||||
class PerfLog {
|
||||
public:
|
||||
PerfLogAction start_action(std::string name);
|
||||
friend td::StringBuilder &operator<<(td::StringBuilder &sb, const PerfLog &log);
|
||||
|
||||
private:
|
||||
struct Entry {
|
||||
std::string name;
|
||||
double begin{};
|
||||
double end{};
|
||||
td::Status status;
|
||||
};
|
||||
std::vector<Entry> entries_;
|
||||
friend class PerfLogAction;
|
||||
|
||||
double finish_action(size_t i, td::Status status);
|
||||
};
|
||||
template <class T>
|
||||
double PerfLogAction::finish(const T &result) {
|
||||
if (result.is_ok()) {
|
||||
return perf_log_->finish_action(i_, td::Status::OK());
|
||||
} else {
|
||||
return perf_log_->finish_action(i_, result.error().clone());
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace td
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue