From 2b905d1d35af7fbdba391f0f0d8d7a28a3d703e8 Mon Sep 17 00:00:00 2001 From: Patrick Jackson Date: Fri, 31 Mar 2023 17:44:13 -0700 Subject: [PATCH] Replace unnecessary Sync with std::atomic --- src/libstore/store-api.cc | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc index 3cf4c801b..60e87918a 100644 --- a/src/libstore/store-api.cc +++ b/src/libstore/store-api.cc @@ -10,7 +10,6 @@ #include "archive.hh" #include "callback.hh" #include "remote-store.hh" -#include "sync.hh" #include #include @@ -1103,7 +1102,7 @@ std::map copyPaths( }; // total is accessed by each copy, which are each handled in separate threads - Sync _total = 0; + std::atomic total = 0; for (auto & missingPath : sortedMissing) { auto info = srcStore.queryPathInfo(missingPath); @@ -1126,9 +1125,8 @@ std::map copyPaths( PushActivity pact(act.id); LambdaSink progressSink([&](std::string_view data) { - auto total(_total.lock()); - *total += data.size(); - act.progress(*total, info->narSize); + total += data.size(); + act.progress(total, info->narSize); }); TeeSink tee { sink, progressSink };