summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2024-07-19 15:36:50 +0200
committerPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2024-07-23 10:24:37 +0200
commit9c9175b8658cade244272464ede3c21be34df172 (patch)
treeedbc5ccd1e2524e5e882ec21484b4d281eed9f70 /src
parent69a5e84e420aa16022baeb146931cd6da43f6305 (diff)
downloadjustbuild-9c9175b8658cade244272464ede3c21be34df172.tar.gz
just-mr: Pass progress and statistics instances to reporter
Diffstat (limited to 'src')
-rw-r--r--src/other_tools/just_mr/TARGETS3
-rw-r--r--src/other_tools/just_mr/fetch.cpp4
-rw-r--r--src/other_tools/just_mr/progress_reporting/TARGETS11
-rw-r--r--src/other_tools/just_mr/progress_reporting/progress_reporter.cpp26
-rw-r--r--src/other_tools/just_mr/progress_reporting/progress_reporter.hpp10
-rw-r--r--src/other_tools/just_mr/setup.cpp4
-rw-r--r--src/other_tools/just_mr/update.cpp4
7 files changed, 38 insertions, 24 deletions
diff --git a/src/other_tools/just_mr/TARGETS b/src/other_tools/just_mr/TARGETS
index af4ef8df..bd6d1ae6 100644
--- a/src/other_tools/just_mr/TARGETS
+++ b/src/other_tools/just_mr/TARGETS
@@ -126,6 +126,7 @@
, "exit_codes"
, ["src/other_tools/just_mr/progress_reporting", "progress"]
, ["src/other_tools/just_mr/progress_reporting", "progress_reporter"]
+ , ["src/other_tools/just_mr/progress_reporting", "statistics"]
, ["src/other_tools/ops_maps", "archive_fetch_map"]
, ["src/other_tools/ops_maps", "content_cas_map"]
, ["src/other_tools/ops_maps", "critical_git_op_map"]
@@ -162,6 +163,7 @@
, "exit_codes"
, ["src/other_tools/just_mr/progress_reporting", "progress"]
, ["src/other_tools/just_mr/progress_reporting", "progress_reporter"]
+ , ["src/other_tools/just_mr/progress_reporting", "statistics"]
, "utils"
, ["src/other_tools/ops_maps", "git_update_map"]
]
@@ -190,6 +192,7 @@
, "exit_codes"
, ["src/other_tools/just_mr/progress_reporting", "progress"]
, ["src/other_tools/just_mr/progress_reporting", "progress_reporter"]
+ , ["src/other_tools/just_mr/progress_reporting", "statistics"]
, "utils"
, ["src/other_tools/ops_maps", "content_cas_map"]
, ["src/other_tools/ops_maps", "critical_git_op_map"]
diff --git a/src/other_tools/just_mr/fetch.cpp b/src/other_tools/just_mr/fetch.cpp
index ed585d80..328f0d74 100644
--- a/src/other_tools/just_mr/fetch.cpp
+++ b/src/other_tools/just_mr/fetch.cpp
@@ -35,6 +35,7 @@
#include "src/other_tools/just_mr/exit_codes.hpp"
#include "src/other_tools/just_mr/progress_reporting/progress.hpp"
#include "src/other_tools/just_mr/progress_reporting/progress_reporter.hpp"
+#include "src/other_tools/just_mr/progress_reporting/statistics.hpp"
#include "src/other_tools/just_mr/setup_utils.hpp"
#include "src/other_tools/ops_maps/archive_fetch_map.hpp"
#include "src/other_tools/ops_maps/content_cas_map.hpp"
@@ -520,7 +521,8 @@ auto MultiRepoFetch(std::shared_ptr<Configuration> const& config,
JustMRProgress::Instance().SetTotal(static_cast<int>(nr_a + nr_gt));
std::atomic<bool> done{false};
std::condition_variable cv{};
- auto reporter = JustMRProgressReporter::Reporter();
+ auto reporter = JustMRProgressReporter::Reporter(
+ &JustMRStatistics::Instance(), &JustMRProgress::Instance());
auto observer =
std::thread([reporter, &done, &cv]() { reporter(&done, &cv); });
diff --git a/src/other_tools/just_mr/progress_reporting/TARGETS b/src/other_tools/just_mr/progress_reporting/TARGETS
index 78fa7b87..e1e42016 100644
--- a/src/other_tools/just_mr/progress_reporting/TARGETS
+++ b/src/other_tools/just_mr/progress_reporting/TARGETS
@@ -17,13 +17,16 @@
, "hdrs": ["progress_reporter.hpp"]
, "srcs": ["progress_reporter.cpp"]
, "stage": ["src", "other_tools", "just_mr", "progress_reporting"]
- , "deps": [["src/buildtool/progress_reporting", "base_progress_reporter"]]
- , "private-deps":
+ , "deps":
[ "progress"
, "statistics"
- , ["@", "fmt", "", "fmt"]
- , ["@", "json", "", "json"]
, ["@", "gsl", "", "gsl"]
+ , ["src/buildtool/progress_reporting", "base_progress_reporter"]
+ ]
+ , "private-deps":
+ [ ["@", "fmt", "", "fmt"]
+ , ["@", "json", "", "json"]
+ , ["src/buildtool/logging", "log_level"]
, ["src/buildtool/logging", "logging"]
]
}
diff --git a/src/other_tools/just_mr/progress_reporting/progress_reporter.cpp b/src/other_tools/just_mr/progress_reporting/progress_reporter.cpp
index e7319d5f..54e8b9c5 100644
--- a/src/other_tools/just_mr/progress_reporting/progress_reporter.cpp
+++ b/src/other_tools/just_mr/progress_reporting/progress_reporter.cpp
@@ -14,26 +14,22 @@
#include "src/other_tools/just_mr/progress_reporting/progress_reporter.hpp"
-#include <optional>
-#include <string>
-
#include "fmt/core.h"
-#include "gsl/gsl"
#include "nlohmann/json.hpp"
#include "src/buildtool/logging/log_level.hpp"
#include "src/buildtool/logging/logger.hpp"
-#include "src/other_tools/just_mr/progress_reporting/progress.hpp"
-#include "src/other_tools/just_mr/progress_reporting/statistics.hpp"
-auto JustMRProgressReporter::Reporter() noexcept -> progress_reporter_t {
- return BaseProgressReporter::Reporter([]() {
- int total = JustMRProgress::Instance().GetTotal();
- auto const& stats = JustMRStatistics::Instance();
- int local = stats.LocalPathsCounter();
- int cached = stats.CacheHitsCounter();
- int run = stats.ExecutedCounter();
- auto active = JustMRProgress::Instance().TaskTracker().Active();
- auto sample = JustMRProgress::Instance().TaskTracker().Sample();
+auto JustMRProgressReporter::Reporter(
+ gsl::not_null<JustMRStatistics*> const& stats,
+ gsl::not_null<JustMRProgress*> const& progress) noexcept
+ -> progress_reporter_t {
+ return BaseProgressReporter::Reporter([stats, progress]() {
+ int total = progress->GetTotal();
+ int local = stats->LocalPathsCounter();
+ int cached = stats->CacheHitsCounter();
+ int run = stats->ExecutedCounter();
+ auto active = progress->TaskTracker().Active();
+ auto sample = progress->TaskTracker().Sample();
std::string msg;
msg = fmt::format("{} local, {} cached, {} done", local, cached, run);
if ((active > 0) && !sample.empty()) {
diff --git a/src/other_tools/just_mr/progress_reporting/progress_reporter.hpp b/src/other_tools/just_mr/progress_reporting/progress_reporter.hpp
index e70b9b33..56461e28 100644
--- a/src/other_tools/just_mr/progress_reporting/progress_reporter.hpp
+++ b/src/other_tools/just_mr/progress_reporting/progress_reporter.hpp
@@ -15,11 +15,17 @@
#ifndef INCLUDED_SRC_OTHER_TOOLS_JUST_MR_PROGRESS_REPORTING_PROGRESS_REPORTER_HPP
#define INCLUDED_SRC_OTHER_TOOLS_JUST_MR_PROGRESS_REPORTING_PROGRESS_REPORTER_HPP
+#include "gsl/gsl"
#include "src/buildtool/progress_reporting/base_progress_reporter.hpp"
+#include "src/other_tools/just_mr/progress_reporting/progress.hpp"
+#include "src/other_tools/just_mr/progress_reporting/statistics.hpp"
-class JustMRProgressReporter {
+class JustMRProgressReporter final {
public:
- [[nodiscard]] static auto Reporter() noexcept -> progress_reporter_t;
+ [[nodiscard]] static auto Reporter(
+ gsl::not_null<JustMRStatistics*> const& stats,
+ gsl::not_null<JustMRProgress*> const& progress) noexcept
+ -> progress_reporter_t;
};
#endif // INCLUDED_SRC_OTHER_TOOLS_JUST_MR_PROGRESS_REPORTING_PROGRESS_REPORTER_HPP
diff --git a/src/other_tools/just_mr/setup.cpp b/src/other_tools/just_mr/setup.cpp
index 6822beb4..8359fec7 100644
--- a/src/other_tools/just_mr/setup.cpp
+++ b/src/other_tools/just_mr/setup.cpp
@@ -39,6 +39,7 @@
#include "src/other_tools/just_mr/exit_codes.hpp"
#include "src/other_tools/just_mr/progress_reporting/progress.hpp"
#include "src/other_tools/just_mr/progress_reporting/progress_reporter.hpp"
+#include "src/other_tools/just_mr/progress_reporting/statistics.hpp"
#include "src/other_tools/just_mr/setup_utils.hpp"
#include "src/other_tools/just_mr/utils.hpp"
#include "src/other_tools/ops_maps/content_cas_map.hpp"
@@ -320,7 +321,8 @@ auto MultiRepoSetup(std::shared_ptr<Configuration> const& config,
JustMRProgress::Instance().SetTotal(setup_repos->to_setup.size());
std::atomic<bool> done{false};
std::condition_variable cv{};
- auto reporter = JustMRProgressReporter::Reporter();
+ auto reporter = JustMRProgressReporter::Reporter(
+ &JustMRStatistics::Instance(), &JustMRProgress::Instance());
auto observer =
std::thread([reporter, &done, &cv]() { reporter(&done, &cv); });
diff --git a/src/other_tools/just_mr/update.cpp b/src/other_tools/just_mr/update.cpp
index cb40766a..449d8841 100644
--- a/src/other_tools/just_mr/update.cpp
+++ b/src/other_tools/just_mr/update.cpp
@@ -30,6 +30,7 @@
#include "src/other_tools/just_mr/exit_codes.hpp"
#include "src/other_tools/just_mr/progress_reporting/progress.hpp"
#include "src/other_tools/just_mr/progress_reporting/progress_reporter.hpp"
+#include "src/other_tools/just_mr/progress_reporting/statistics.hpp"
#include "src/other_tools/just_mr/utils.hpp"
#include "src/other_tools/ops_maps/git_update_map.hpp"
@@ -227,7 +228,8 @@ auto MultiRepoUpdate(std::shared_ptr<Configuration> const& config,
JustMRProgress::Instance().SetTotal(repos_to_update.size());
std::atomic<bool> done{false};
std::condition_variable cv{};
- auto reporter = JustMRProgressReporter::Reporter();
+ auto reporter = JustMRProgressReporter::Reporter(
+ &JustMRStatistics::Instance(), &JustMRProgress::Instance());
auto observer =
std::thread([reporter, &done, &cv]() { reporter(&done, &cv); });