about summary refs log tree commit diff
path: root/library/std/src/sync/barrier.rs
diff options
context:
space:
mode:
authorStuart Cook <Zalathar@users.noreply.github.com>2025-08-30 20:29:06 +1000
committerGitHub <noreply@github.com>2025-08-30 20:29:06 +1000
commiteda6dc928323fcd0ac1b51cea1aa79ab17e8519d (patch)
treec6b973e6d858c85b47f0f3bdeeeeb7b4707fed18 /library/std/src/sync/barrier.rs
parent6421031e5765cf9bae01edb5f0d6c1d2cc25a927 (diff)
parentd210ce7dac4acb7653d647c77d56c10068dda82c (diff)
downloadrust-eda6dc928323fcd0ac1b51cea1aa79ab17e8519d.tar.gz
rust-eda6dc928323fcd0ac1b51cea1aa79ab17e8519d.zip
Rollup merge of #144651 - connortsui20:nonpoison_condvar, r=joboet
Implementation: `#[feature(nonpoison_condvar)]`

Tracking Issue: https://github.com/rust-lang/rust/issues/134645

This PR continues the effort made in https://github.com/rust-lang/rust/pull/144022 by adding the implementation of `nonpoison::condvar`.

Many of the changes here are similar to the changes made to implement `nonpoison::mutex`.

There are two other changes here. The first is that the `Barrier` implementation is migrated to use the `nonpoison::Condvar` instead of the `poison` variant. The second (which might be subject to some discussion) is that `WaitTimeoutResult` is moved up to `mod.rs`, as both `condvar` variants need that type (and I do not know if there is a better place to put it now).

### Related PRs

- `nonpoison_rwlock` implementation: https://github.com/rust-lang/rust/pull/144648
- `nonpoison_once` implementation: https://github.com/rust-lang/rust/pull/144653
Diffstat (limited to 'library/std/src/sync/barrier.rs')
-rw-r--r--library/std/src/sync/barrier.rs8
1 files changed, 3 insertions, 5 deletions
diff --git a/library/std/src/sync/barrier.rs b/library/std/src/sync/barrier.rs
index 067ff66d9af..712ce03f90b 100644
--- a/library/std/src/sync/barrier.rs
+++ b/library/std/src/sync/barrier.rs
@@ -1,6 +1,5 @@
 use crate::fmt;
-// FIXME(nonpoison_mutex,nonpoison_condvar): switch to nonpoison versions once they are available
-use crate::sync::{Condvar, Mutex};
+use crate::sync::nonpoison::{Condvar, Mutex};
 
 /// A barrier enables multiple threads to synchronize the beginning
 /// of some computation.
@@ -118,12 +117,11 @@ impl Barrier {
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
     pub fn wait(&self) -> BarrierWaitResult {
-        let mut lock = self.lock.lock().unwrap();
+        let mut lock = self.lock.lock();
         let local_gen = lock.generation_id;
         lock.count += 1;
         if lock.count < self.num_threads {
-            let _guard =
-                self.cvar.wait_while(lock, |state| local_gen == state.generation_id).unwrap();
+            let _guard = self.cvar.wait_while(lock, |state| local_gen == state.generation_id);
             BarrierWaitResult(false)
         } else {
             lock.count = 0;