Skip to content

Commit

Permalink
task: mark JoinHandle as UnwindSafe (#4418)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hodkinson committed Jan 24, 2022
1 parent 9a57a6a commit 9e38ebc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
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

0 comments on commit 9e38ebc

Please sign in to comment.