diff options
author | Haibo Huang <hhb@google.com> | 2020-11-18 21:40:25 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2020-11-18 21:40:25 +0000 |
commit | 367d188acf3cb6119fe468a8af0eaaf1938b23aa (patch) | |
tree | f7712e80e98ece82b3798c0ff1b9e81bc15058f1 | |
parent | 0443fdcd81c490499c1055913968c9a754067e45 (diff) | |
parent | 070847fd1d56261bb5e56537f4f07388543056b9 (diff) | |
download | parking_lot-367d188acf3cb6119fe468a8af0eaaf1938b23aa.tar.gz |
Upgrade rust/crates/parking_lot to 0.11.1 am: 38593b516c am: 070847fd1d
Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/parking_lot/+/1502430
Change-Id: I87302f0f806445a32c72c44cc1727198aeda15ab
-rw-r--r-- | .cargo_vcs_info.json | 2 | ||||
-rw-r--r-- | .github/workflows/rust.yml | 65 | ||||
-rw-r--r-- | .travis.yml | 91 | ||||
-rw-r--r-- | Android.bp | 13 | ||||
-rw-r--r-- | CHANGELOG.md | 10 | ||||
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | Cargo.toml.orig | 2 | ||||
-rw-r--r-- | METADATA | 8 | ||||
-rw-r--r-- | src/condvar.rs | 3 | ||||
-rw-r--r-- | src/raw_rwlock.rs | 6 | ||||
-rw-r--r-- | src/rwlock.rs | 11 |
11 files changed, 102 insertions, 111 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json index ef88cf4..e1a0b04 100644 --- a/.cargo_vcs_info.json +++ b/.cargo_vcs_info.json @@ -1,5 +1,5 @@ { "git": { - "sha1": "8c154bedcb392b87feea9b29054f3f0cabcd6a28" + "sha1": "86969fd7baf94312520e0b5a5f3b0861a0fd411b" } } diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml new file mode 100644 index 0000000..d613089 --- /dev/null +++ b/.github/workflows/rust.yml @@ -0,0 +1,65 @@ +name: Rust + +on: + push: + branches-ignore: + - trying.tmp + - staging.tmp + pull_request: + +env: + RUST_TEST_THREADS: 1 + +jobs: + build_tier_one: + runs-on: ${{ matrix.os }}-latest + strategy: + matrix: + os: [ubuntu, macos, windows] + channel: [1.36.0, stable, beta, nightly] + feature: [serde, deadlock_detection] + exclude: + - feature: deadlock_detection + channel: '1.36.0' + include: + - channel: nightly + feature: nightly + os: ubuntu + + steps: + - uses: actions/checkout@v2 + - run: rustup default ${{ matrix.channel }} + - run: cargo build --all + - run: cargo test --all + - run: cargo build --all --features ${{ matrix.feature }} + - run: cargo test --all --features ${{ matrix.feature }} + if: matrix.feature == 'nightly' + build_other_platforms: + runs-on: ubuntu-latest + strategy: + matrix: + target: + - wasm32-unknown-unknown + - x86_64-fortanix-unknown-sgx + #- x86_64-unknown-redox + #- x86_64-linux-android + steps: + - uses: actions/checkout@v2 + - run: rustup default nightly + - run: rustup target add ${{ matrix.target }} + - run: cargo build --workspace --target ${{ matrix.target }} --features nightly + build_docs: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: rustup default nightly + - run: cargo doc --workspace --features serde,deadlock_detection --no-deps -p parking_lot -p parking_lot_core -p lock_api + benchmark: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: rustup default nightly + - run: | + cd benchmark + cargo run --release --bin mutex -- 2 1 0 1 2 + cargo run --release --bin rwlock -- 1 1 1 0 1 2 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 7cbf56a..0000000 --- a/.travis.yml +++ /dev/null @@ -1,91 +0,0 @@ -language: rust -sudo: false - -env: - global: - - RUST_TEST_THREADS=1 - -matrix: - include: - - rust: 1.36.0 - os: linux - script: - - cargo build --lib - - cargo build --lib --features serde - # Build on other platforms - - rustup target add wasm32-unknown-unknown - - cargo build --lib --target wasm32-unknown-unknown - - - rust: 1.36.0 - os: linux - script: &script - - cargo build - - cargo test --all - - cargo build --features serde - - cargo test --features serde - - cargo test --features=deadlock_detection - # Test other platforms - - rustup target add wasm32-unknown-unknown - - cargo build --all --target wasm32-unknown-unknown - - - rust: stable - os: linux - script: *script - - - rust: beta - os: linux - script: *script - - - rust: nightly - os: linux - script: - - cargo build --features nightly - - cargo test --all --features nightly - - cargo build --features serde,nightly - - cargo test --all --features serde,nightly - # Test other platforms - - rustup target add x86_64-fortanix-unknown-sgx - - rustup target add x86_64-unknown-redox - - rustup target add x86_64-unknown-cloudabi - - rustup target add x86_64-linux-android - - cargo test --all --no-run --target x86_64-fortanix-unknown-sgx --features nightly - - cargo build --all --target x86_64-unknown-redox --features nightly - - cargo build --all --target x86_64-unknown-cloudabi --features nightly - - cargo build --all --target x86_64-linux-android --features nightly - # Test building the docs - - cargo doc --all-features --no-deps -p parking_lot -p parking_lot_core -p lock_api - # Run the benchmarks - - cd benchmark - - cargo run --release --bin mutex -- 2 1 0 1 2 - - cargo run --release --bin rwlock -- 1 1 1 0 1 2 - - cd .. - - - rust: 1.36.0 - os: osx - script: *script - - - rust: stable - os: osx - script: *script - - - rust: beta - os: osx - script: *script - - - rust: nightly - os: osx - script: - - cargo build --features nightly - - cargo test --all --features nightly - - cargo build --features serde,nightly - - cargo test --all --features serde,nightly - -notifications: - email: false - -branches: - # Don't build these branches - except: - # Used by bors - - trying.tmp - - staging.tmp @@ -6,9 +6,7 @@ rust_library { crate_name: "parking_lot", srcs: ["src/lib.rs"], edition: "2018", - features: [ - "default", - ], + features: ["default"], rustlibs: [ "libinstant", "liblock_api", @@ -18,9 +16,10 @@ rust_library { // dependent_library ["feature_list"] // cfg-if-0.1.10 -// instant-0.1.7 -// libc-0.2.79 "default,std" -// lock_api-0.4.1 +// cfg-if-1.0.0 +// instant-0.1.8 +// libc-0.2.80 "default,std" +// lock_api-0.4.2 // parking_lot_core-0.8.0 // scopeguard-1.1.0 -// smallvec-1.4.2 +// smallvec-1.5.0 diff --git a/CHANGELOG.md b/CHANGELOG.md index 661a49a..a473463 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +## parking_lot 0.11.1, lock_api 0.4.2 (2020-11-18) + +- Fix bounds on Send and Sync impls for lock guards. (#262) +- Fix incorrect memory ordering in `RwLock`. (#260) + +## lock_api 0.4.1 (2020-07-06) + +- Add `data_ptr` method to lock types to allow unsafely accessing the inner data + without a guard. (#247) + ## parking_lot 0.11.0, parking_lot_core 0.8.0, lock_api 0.4.0 (2020-06-23) - Add `is_locked` method to mutex types. (#235) @@ -13,7 +13,7 @@ [package] edition = "2018" name = "parking_lot" -version = "0.11.0" +version = "0.11.1" authors = ["Amanieu d'Antras <amanieu@gmail.com>"] description = "More compact and efficient implementations of the standard synchronization primitives." readme = "README.md" diff --git a/Cargo.toml.orig b/Cargo.toml.orig index 1564fa4..67a2555 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -1,6 +1,6 @@ [package] name = "parking_lot" -version = "0.11.0" +version = "0.11.1" authors = ["Amanieu d'Antras <amanieu@gmail.com>"] description = "More compact and efficient implementations of the standard synchronization primitives." license = "Apache-2.0/MIT" @@ -7,13 +7,13 @@ third_party { } url { type: ARCHIVE - value: "https://static.crates.io/crates/parking_lot/parking_lot-0.11.0.crate" + value: "https://static.crates.io/crates/parking_lot/parking_lot-0.11.1.crate" } - version: "0.11.0" + version: "0.11.1" license_type: NOTICE last_upgrade_date { year: 2020 - month: 10 - day: 20 + month: 11 + day: 17 } } diff --git a/src/condvar.rs b/src/condvar.rs index 5451168..534b8af 100644 --- a/src/condvar.rs +++ b/src/condvar.rs @@ -663,6 +663,9 @@ mod tests { while !c.notify_one() { // Wait for the thread to get into wait() MutexGuard::bump(&mut g); + // Yield, so the other thread gets a chance to do something. + // (At least Miri needs this, because it doesn't preempt threads.) + thread::yield_now(); } // The thread should have been requeued to the mutex, which we wake up now. drop(g); diff --git a/src/raw_rwlock.rs b/src/raw_rwlock.rs index 1feb0bd..75a9812 100644 --- a/src/raw_rwlock.rs +++ b/src/raw_rwlock.rs @@ -970,11 +970,11 @@ impl RawRwLock { // At this point WRITER_BIT is already set, we just need to wait for the // remaining readers to exit the lock. let mut spinwait = SpinWait::new(); - let mut state = self.state.load(Ordering::Relaxed); + let mut state = self.state.load(Ordering::Acquire); while state & READERS_MASK != 0 { // Spin a few times to wait for readers to exit if spinwait.spin() { - state = self.state.load(Ordering::Relaxed); + state = self.state.load(Ordering::Acquire); continue; } @@ -1019,7 +1019,7 @@ impl RawRwLock { // since a previous writer timing-out could have allowed // another reader to sneak in before we parked. ParkResult::Unparked(_) | ParkResult::Invalid => { - state = self.state.load(Ordering::Relaxed); + state = self.state.load(Ordering::Acquire); continue; } diff --git a/src/rwlock.rs b/src/rwlock.rs index 89987c6..70e1b1a 100644 --- a/src/rwlock.rs +++ b/src/rwlock.rs @@ -539,8 +539,8 @@ mod tests { fn test_rwlock_recursive() { let arc = Arc::new(RwLock::new(1)); let arc2 = arc.clone(); - let _lock1 = arc.read(); - thread::spawn(move || { + let lock1 = arc.read(); + let t = thread::spawn(move || { let _lock = arc2.write(); }); @@ -554,7 +554,12 @@ mod tests { } // A normal read would block here since there is a pending writer - let _lock2 = arc.read_recursive(); + let lock2 = arc.read_recursive(); + + // Unblock the thread and join it. + drop(lock1); + drop(lock2); + t.join().unwrap(); } #[test] |