Make Barrier RefUnwindSafe again
This commit manually implements `RefUnwindSafe` for
`std::sync::Barrier` to fix 146087. This is a fix for a regression
indroduced by e95db591a4
This commit is contained in:
parent
2f3f27bf79
commit
20d02258fc
2 changed files with 15 additions and 0 deletions
|
|
@ -1,3 +1,5 @@
|
|||
use core::panic::RefUnwindSafe;
|
||||
|
||||
use crate::fmt;
|
||||
use crate::sync::nonpoison::{Condvar, Mutex};
|
||||
|
||||
|
|
@ -31,6 +33,9 @@ pub struct Barrier {
|
|||
num_threads: usize,
|
||||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl RefUnwindSafe for Barrier {}
|
||||
|
||||
// The inner state of a double barrier
|
||||
struct BarrierState {
|
||||
count: usize,
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
use std::panic::RefUnwindSafe;
|
||||
use std::sync::mpsc::{TryRecvError, channel};
|
||||
use std::sync::{Arc, Barrier};
|
||||
use std::thread;
|
||||
|
|
@ -33,3 +34,12 @@ fn test_barrier() {
|
|||
}
|
||||
assert!(leader_found);
|
||||
}
|
||||
|
||||
#[expect(dead_code, reason = "this is essentially a compile pass test")]
|
||||
fn check_barrier_is_ref_unwind_safe() {
|
||||
let barrier = Arc::new(Barrier::new(10));
|
||||
|
||||
fn check<T: RefUnwindSafe>(_: T) {}
|
||||
|
||||
check(barrier);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue