Skip to content

Commit a8163bd

Browse files
committed
change Barrier implementation to use nonpoison::Condvar
Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
1 parent b2380d2 commit a8163bd

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

library/std/src/sync/barrier.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use crate::fmt;
2-
// FIXME(nonpoison_mutex,nonpoison_condvar): switch to nonpoison versions once they are available
3-
use crate::sync::{Condvar, Mutex};
2+
use crate::sync::nonpoison::{Condvar, Mutex};
43

54
/// A barrier enables multiple threads to synchronize the beginning
65
/// of some computation.
@@ -118,12 +117,11 @@ impl Barrier {
118117
/// ```
119118
#[stable(feature = "rust1", since = "1.0.0")]
120119
pub fn wait(&self) -> BarrierWaitResult {
121-
let mut lock = self.lock.lock().unwrap();
120+
let mut lock = self.lock.lock();
122121
let local_gen = lock.generation_id;
123122
lock.count += 1;
124123
if lock.count < self.num_threads {
125-
let _guard =
126-
self.cvar.wait_while(lock, |state| local_gen == state.generation_id).unwrap();
124+
let _guard = self.cvar.wait_while(lock, |state| local_gen == state.generation_id);
127125
BarrierWaitResult(false)
128126
} else {
129127
lock.count = 0;

0 commit comments

Comments
 (0)