Skip to content

Commit

Permalink
Auto merge of #13273 - BD103:master, r=weihanglo
Browse files Browse the repository at this point in the history
Document why `du` function uses mutex

### What does this PR try to resolve?

After closing #13253, it [was suggested](#13253 (comment)) to document why the `du` function uses a `Mutex` instead of an `AtomicU64`. This will prevent others from making the same mistake I did. :)

### How should we test and review this PR?

N/A

### Additional information

N/A
  • Loading branch information
bors committed Jan 10, 2024
2 parents 3e428a3 + 0a6fe23 commit 187d4cf
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/cargo-util/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cargo-util"
version = "0.2.9"
version = "0.2.10"
rust-version.workspace = true
edition.workspace = true
license.workspace = true
Expand Down
7 changes: 7 additions & 0 deletions crates/cargo-util/src/du.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,14 @@ fn du_inner(path: &Path, patterns: &[&str]) -> Result<u64> {
.git_ignore(false)
.git_exclude(false);
let walker = builder.build_parallel();

// Platforms like PowerPC don't support AtomicU64, so we use a Mutex instead.
//
// See:
// - https://github.com/rust-lang/cargo/pull/12981
// - https://github.com/rust-lang/rust/pull/117916#issuecomment-1812635848
let total = Arc::new(Mutex::new(0u64));

// A slot used to indicate there was an error while walking.
//
// It is possible that more than one error happens (such as in different
Expand Down

0 comments on commit 187d4cf

Please sign in to comment.