diff options
author | Carl Lerche <me@carllerche.com> | 2019-08-31 12:18:55 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-31 12:18:55 -0700 |
commit | 431d4857e89b0fcc77d37277e7ff15a50ffb9e47 (patch) | |
tree | 1fd928e306e4f33dff8425575e4017d3ee1e3cbb /tokio-io | |
parent | 26432355d59a8470e97ea1e58b82f512ed3ac06f (diff) |
io: add Send / Sync impls for ReadHalf / WriteHalf (#1525)
Diffstat (limited to 'tokio-io')
-rw-r--r-- | tokio-io/src/split.rs | 5 | ||||
-rw-r--r-- | tokio-io/tests/split.rs | 9 |
2 files changed, 14 insertions, 0 deletions
diff --git a/tokio-io/src/split.rs b/tokio-io/src/split.rs index d13f9882..0fd0ebbc 100644 --- a/tokio-io/src/split.rs +++ b/tokio-io/src/split.rs @@ -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() diff --git a/tokio-io/tests/split.rs b/tokio-io/tests/split.rs index f9c0c07f..7be96241 100644 --- a/tokio-io/tests/split.rs +++ b/tokio-io/tests/split.rs @@ -1,4 +1,5 @@ use tokio::io::{split, AsyncRead, AsyncWrite}; +use tokio_io::split::{ReadHalf, WriteHalf}; use std::io; use std::pin::Pin; @@ -35,6 +36,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); r.unsplit(w); |