mirror of
https://github.com/tokio-rs/tokio.git
synced 2025-09-28 12:10:37 +00:00
io: add Send / Sync impls for ReadHalf / WriteHalf (#1525)
This commit is contained in:
parent
26432355d5
commit
431d4857e8
@ -160,6 +160,11 @@ impl<T> Drop for Guard<'_, T> {
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl<T: Send> Send for ReadHalf<T> {}
|
||||
unsafe impl<T: Send> Send for WriteHalf<T> {}
|
||||
unsafe impl<T: Sync> Sync for ReadHalf<T> {}
|
||||
unsafe impl<T: Sync> Sync for WriteHalf<T> {}
|
||||
|
||||
impl<T: fmt::Debug> fmt::Debug for ReadHalf<T> {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
fmt.debug_struct("split::ReadHalf").finish()
|
||||
|
@ -1,4 +1,5 @@
|
||||
use tokio::io::{split, AsyncRead, AsyncWrite};
|
||||
use tokio_io::split::{ReadHalf, WriteHalf};
|
||||
|
||||
use std::io;
|
||||
use std::pin::Pin;
|
||||
@ -34,6 +35,14 @@ impl AsyncWrite for RW {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn is_send_and_sync() {
|
||||
fn assert_bound<T: Send + Sync>() {}
|
||||
|
||||
assert_bound::<ReadHalf<RW>>();
|
||||
assert_bound::<WriteHalf<RW>>();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unsplit_ok() {
|
||||
let (r, w) = split(RW);
|
||||
|
Loading…
x
Reference in New Issue
Block a user