From 1b4917d40e5b4bbfeae5146bc826299bbc27898f Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Mon, 22 Jul 2024 18:32:24 +0200 Subject: just-mr: Remove progress and statistics singletons ...and instead use simple instances created in setup, fetch, and update, respectively. The various maps and the progress reporter get access to these instances via not_null pointers. --- src/other_tools/just_mr/fetch.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/other_tools/just_mr/fetch.cpp') diff --git a/src/other_tools/just_mr/fetch.cpp b/src/other_tools/just_mr/fetch.cpp index 11a11306..b6495a6f 100644 --- a/src/other_tools/just_mr/fetch.cpp +++ b/src/other_tools/just_mr/fetch.cpp @@ -473,6 +473,10 @@ auto MultiRepoFetch(std::shared_ptr const& config, } } + // setup progress and statistics instances + JustMRStatistics stats{}; + JustMRProgress progress{nr_a + nr_gt}; + // create async maps auto crit_git_op_ptr = std::make_shared(); auto critical_git_op_map = CreateCriticalGitOpMap(crit_git_op_ptr); @@ -487,7 +491,7 @@ auto MultiRepoFetch(std::shared_ptr const& config, &storage, &(*apis.local), has_remote_api ? &*apis.remote : nullptr, - &JustMRProgress::Instance(), + &progress, common_args.jobs); auto archive_fetch_map = CreateArchiveFetchMap( @@ -497,7 +501,7 @@ auto MultiRepoFetch(std::shared_ptr const& config, &(*apis.local), (fetch_args.backup_to_remote and has_remote_api) ? &*apis.remote : nullptr, - &JustMRStatistics::Instance(), + &stats, common_args.jobs); auto import_to_git_map = @@ -517,15 +521,13 @@ auto MultiRepoFetch(std::shared_ptr const& config, &(*apis.local), has_remote_api ? &*apis.remote : nullptr, fetch_args.backup_to_remote, - &JustMRProgress::Instance(), + &progress, common_args.jobs); // set up progress observer - JustMRProgress::Instance().SetTotal(static_cast(nr_a + nr_gt)); std::atomic done{false}; std::condition_variable cv{}; - auto reporter = JustMRProgressReporter::Reporter( - &JustMRStatistics::Instance(), &JustMRProgress::Instance()); + auto reporter = JustMRProgressReporter::Reporter(&stats, &progress); auto observer = std::thread([reporter, &done, &cv]() { reporter(&done, &cv); }); -- cgit v1.2.3