mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-22 00:00:11 +02:00
sync: make Notify panic safe (#5154)
This commit is contained in:
@@ -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<()>>();
|
||||
|
||||
Reference in New Issue
Block a user