mirror of
https://github.com/tokio-rs/tokio.git
synced 2025-09-28 12:10:37 +00:00
sync: make Notify
panic safe (#5154)
This commit is contained in:
parent
b1f40f4356
commit
203a079743
@ -13,6 +13,7 @@ use crate::util::WakeList;
|
||||
use std::cell::UnsafeCell;
|
||||
use std::future::Future;
|
||||
use std::marker::PhantomPinned;
|
||||
use std::panic::{RefUnwindSafe, UnwindSafe};
|
||||
use std::pin::Pin;
|
||||
use std::ptr::NonNull;
|
||||
use std::sync::atomic::Ordering::SeqCst;
|
||||
@ -566,6 +567,9 @@ impl Default for Notify {
|
||||
}
|
||||
}
|
||||
|
||||
impl UnwindSafe for Notify {}
|
||||
impl RefUnwindSafe for Notify {}
|
||||
|
||||
fn notify_locked(waiters: &mut WaitList, state: &AtomicUsize, curr: usize) -> Option<Waker> {
|
||||
loop {
|
||||
match get_state(curr) {
|
||||
|
@ -3,6 +3,11 @@
|
||||
|
||||
use std::panic::{RefUnwindSafe, UnwindSafe};
|
||||
|
||||
#[test]
|
||||
fn notify_is_unwind_safe() {
|
||||
is_unwind_safe::<tokio::sync::Notify>();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn join_handle_is_unwind_safe() {
|
||||
is_unwind_safe::<tokio::task::JoinHandle<()>>();
|
||||
|
Loading…
x
Reference in New Issue
Block a user