Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runtime: mark JoinHandle as UnwindSafe (#4414) #4418

Merged
merged 2 commits into from Jan 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions tokio/src/runtime/task/join.rs
Expand Up @@ -3,6 +3,7 @@ use crate::runtime::task::RawTask;
use std::fmt;
use std::future::Future;
use std::marker::PhantomData;
use std::panic::{RefUnwindSafe, UnwindSafe};
use std::pin::Pin;
use std::task::{Context, Poll};

Expand Down Expand Up @@ -150,6 +151,9 @@ cfg_rt! {
unsafe impl<T: Send> Send for JoinHandle<T> {}
unsafe impl<T: Send> Sync for JoinHandle<T> {}

impl<T> UnwindSafe for JoinHandle<T> {}
impl<T> RefUnwindSafe for JoinHandle<T> {}

impl<T> JoinHandle<T> {
pub(super) fn new(raw: RawTask) -> JoinHandle<T> {
JoinHandle {
Expand Down
5 changes: 5 additions & 0 deletions tokio/tests/net_types_unwind.rs → tokio/tests/unwindsafe.rs
Expand Up @@ -3,6 +3,11 @@

use std::panic::{RefUnwindSafe, UnwindSafe};

#[test]
fn join_handle_is_unwind_safe() {
is_unwind_safe::<tokio::task::JoinHandle<()>>();
}

#[test]
fn net_types_are_unwind_safe() {
is_unwind_safe::<tokio::net::TcpListener>();
Expand Down