Skip to content

Commit

Permalink
Merge pull request #8142 from patricksjackson/atomic-sync
Browse files Browse the repository at this point in the history
Replace unnecessary Sync<uint64_t> with std::atomic<uint64_t>
  • Loading branch information
Ericson2314 authored Apr 1, 2023
2 parents cf76b38 + 2b905d1 commit 8ae9d66
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/libstore/store-api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include "archive.hh"
#include "callback.hh"
#include "remote-store.hh"
#include "sync.hh"

#include <nlohmann/json.hpp>
#include <regex>
Expand Down Expand Up @@ -1103,7 +1102,7 @@ std::map<StorePath, StorePath> copyPaths(
};

// total is accessed by each copy, which are each handled in separate threads
Sync<uint64_t> _total = 0;
std::atomic<uint64_t> total = 0;

for (auto & missingPath : sortedMissing) {
auto info = srcStore.queryPathInfo(missingPath);
Expand All @@ -1126,9 +1125,8 @@ std::map<StorePath, StorePath> 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 };

Expand Down

0 comments on commit 8ae9d66

Please sign in to comment.