diff options
author | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2024-07-22 16:05:53 +0200 |
---|---|---|
committer | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2024-07-23 10:24:39 +0200 |
commit | 4a9c4f50cc0ad0bcd4b26a027c4e80d5d43c9f9d (patch) | |
tree | e24499f845a7b4ab4f29eee33a35a976b160b791 /src/other_tools/ops_maps | |
parent | 0aab4ee769211fa90e51926ae4411da29c1c0776 (diff) | |
download | justbuild-4a9c4f50cc0ad0bcd4b26a027c4e80d5d43c9f9d.tar.gz |
just-mr: Use statistics and progress instances update map
...instead of using the singletons.
Diffstat (limited to 'src/other_tools/ops_maps')
-rw-r--r-- | src/other_tools/ops_maps/TARGETS | 7 | ||||
-rw-r--r-- | src/other_tools/ops_maps/git_update_map.cpp | 26 | ||||
-rw-r--r-- | src/other_tools/ops_maps/git_update_map.hpp | 5 |
3 files changed, 24 insertions, 14 deletions
diff --git a/src/other_tools/ops_maps/TARGETS b/src/other_tools/ops_maps/TARGETS index bbcee3f8..548db656 100644 --- a/src/other_tools/ops_maps/TARGETS +++ b/src/other_tools/ops_maps/TARGETS @@ -39,18 +39,19 @@ , "hdrs": ["git_update_map.hpp"] , "srcs": ["git_update_map.cpp"] , "deps": - [ ["src/other_tools/git_operations", "git_repo_remote"] + [ ["@", "gsl", "", "gsl"] + , ["src/other_tools/git_operations", "git_repo_remote"] , ["src/buildtool/multithreading", "async_map_consumer"] , ["src/utils/cpp", "hash_combine"] , ["src/buildtool/storage", "config"] + , ["src/other_tools/just_mr/progress_reporting", "progress"] + , ["src/other_tools/just_mr/progress_reporting", "statistics"] ] , "stage": ["src", "other_tools", "ops_maps"] , "private-deps": [ ["@", "fmt", "", "fmt"] , ["src/buildtool/execution_api/local", "config"] , ["src/buildtool/storage", "fs_utils"] - , ["src/other_tools/just_mr/progress_reporting", "statistics"] - , ["src/other_tools/just_mr/progress_reporting", "progress"] ] } , "content_cas_map": diff --git a/src/other_tools/ops_maps/git_update_map.cpp b/src/other_tools/ops_maps/git_update_map.cpp index de3bfb25..510b9d1c 100644 --- a/src/other_tools/ops_maps/git_update_map.cpp +++ b/src/other_tools/ops_maps/git_update_map.cpp @@ -17,21 +17,25 @@ #include "fmt/core.h" #include "src/buildtool/execution_api/local/config.hpp" #include "src/buildtool/storage/fs_utils.hpp" -#include "src/other_tools/just_mr/progress_reporting/progress.hpp" -#include "src/other_tools/just_mr/progress_reporting/statistics.hpp" auto CreateGitUpdateMap( GitCASPtr const& git_cas, std::string const& git_bin, std::vector<std::string> const& launcher, gsl::not_null<StorageConfig const*> const& storage_config, + gsl::not_null<JustMRStatistics*> const& stats, + gsl::not_null<JustMRProgress*> const& progress, std::size_t jobs) -> GitUpdateMap { - auto update_commits = [git_cas, git_bin, launcher, storage_config]( - auto /* unused */, - auto setter, - auto logger, - auto /* unused */, - auto const& key) { + auto update_commits = [git_cas, + git_bin, + launcher, + storage_config, + stats, + progress](auto /* unused */, + auto setter, + auto logger, + auto /* unused */, + auto const& key) { // perform git update commit auto git_repo = GitRepoRemote::Open(git_cas); // wrap the tmp odb if (not git_repo) { @@ -50,7 +54,7 @@ auto CreateGitUpdateMap( }); // update commit auto id = fmt::format("{}:{}", key.repo, key.branch); - JustMRProgress::Instance().TaskTracker().Start(id); + progress->TaskTracker().Start(id); auto new_commit = git_repo->UpdateCommitViaTmpRepo(*storage_config, key.repo, key.branch, @@ -58,11 +62,11 @@ auto CreateGitUpdateMap( git_bin, launcher, wrapped_logger); - JustMRProgress::Instance().TaskTracker().Stop(id); + progress->TaskTracker().Stop(id); if (not new_commit) { return; } - JustMRStatistics::Instance().IncrementExecutedCounter(); + stats->IncrementExecutedCounter(); (*setter)(new_commit->c_str()); }; return AsyncMapConsumer<RepoDescriptionForUpdating, std::string>( diff --git a/src/other_tools/ops_maps/git_update_map.hpp b/src/other_tools/ops_maps/git_update_map.hpp index 4b043284..cdb9e55a 100644 --- a/src/other_tools/ops_maps/git_update_map.hpp +++ b/src/other_tools/ops_maps/git_update_map.hpp @@ -20,9 +20,12 @@ #include <utility> #include <vector> +#include "gsl/gsl" #include "src/buildtool/multithreading/async_map_consumer.hpp" #include "src/buildtool/storage/config.hpp" #include "src/other_tools/git_operations/git_repo_remote.hpp" +#include "src/other_tools/just_mr/progress_reporting/progress.hpp" +#include "src/other_tools/just_mr/progress_reporting/statistics.hpp" #include "src/utils/cpp/hash_combine.hpp" struct RepoDescriptionForUpdating { @@ -57,6 +60,8 @@ struct hash<RepoDescriptionForUpdating> { std::string const& git_bin, std::vector<std::string> const& launcher, gsl::not_null<StorageConfig const*> const& storage_config, + gsl::not_null<JustMRStatistics*> const& stats, + gsl::not_null<JustMRProgress*> const& progress, std::size_t jobs) -> GitUpdateMap; #endif // INCLUDED_SRC_OTHER_TOOLS_OPS_MAPS_GIT_UPDATE_MAP_HPP |