mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-22 00:00:11 +02:00
net: add UnwindSafe impl to PollEvented (#4384)
This commit is contained in:
@@ -4,6 +4,7 @@ use mio::event::Source;
|
||||
use std::fmt;
|
||||
use std::io;
|
||||
use std::ops::Deref;
|
||||
use std::panic::{RefUnwindSafe, UnwindSafe};
|
||||
|
||||
cfg_io_driver! {
|
||||
/// Associates an I/O resource that implements the [`std::io::Read`] and/or
|
||||
@@ -185,6 +186,10 @@ feature! {
|
||||
}
|
||||
}
|
||||
|
||||
impl<E: Source> UnwindSafe for PollEvented<E> {}
|
||||
|
||||
impl<E: Source> RefUnwindSafe for PollEvented<E> {}
|
||||
|
||||
impl<E: Source> Deref for PollEvented<E> {
|
||||
type Target = E;
|
||||
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
#![warn(rust_2018_idioms)]
|
||||
#![cfg(feature = "full")]
|
||||
|
||||
use std::panic::{RefUnwindSafe, UnwindSafe};
|
||||
|
||||
#[test]
|
||||
fn net_types_are_unwind_safe() {
|
||||
is_unwind_safe::<tokio::net::TcpListener>();
|
||||
is_unwind_safe::<tokio::net::TcpSocket>();
|
||||
is_unwind_safe::<tokio::net::TcpStream>();
|
||||
is_unwind_safe::<tokio::net::UdpSocket>();
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(unix)]
|
||||
fn unix_net_types_are_unwind_safe() {
|
||||
is_unwind_safe::<tokio::net::UnixDatagram>();
|
||||
is_unwind_safe::<tokio::net::UnixListener>();
|
||||
is_unwind_safe::<tokio::net::UnixStream>();
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(windows)]
|
||||
fn windows_net_types_are_unwind_safe() {
|
||||
use tokio::net::windows::named_pipe::NamedPipeClient;
|
||||
use tokio::net::windows::named_pipe::NamedPipeServer;
|
||||
|
||||
is_unwind_safe::<NamedPipeClient>();
|
||||
is_unwind_safe::<NamedPipeServer>();
|
||||
}
|
||||
|
||||
fn is_unwind_safe<T: UnwindSafe + RefUnwindSafe>() {}
|
||||
Reference in New Issue
Block a user