time: remove Box from Sleep (#3278)

Removes the box from `Sleep`, taking advantage of intrusive wakers. The
`Sleep` future is now `!Unpin`.

Closes #3267
This commit is contained in:
Carl Lerche
2020-12-16 21:51:34 -08:00
committed by GitHub
parent 8efa62013b
commit d74d17307d
12 changed files with 104 additions and 69 deletions
+14
View File
@@ -93,6 +93,14 @@ macro_rules! assert_value {
AmbiguousIfSync::some_item(&f);
};
};
($type:ty: Unpin) => {
#[allow(unreachable_code)]
#[allow(unused_variables)]
const _: fn() = || {
let f: $type = todo!();
require_unpin(&f);
};
};
}
macro_rules! async_assert_fn {
($($f:ident $(< $($generic:ty),* > )? )::+($($arg:ty),*): Send & Sync) => {
@@ -280,6 +288,12 @@ async_assert_fn!(tokio::time::timeout_at(Instant, BoxFutureSend<()>): Send & !Sy
async_assert_fn!(tokio::time::timeout_at(Instant, BoxFuture<()>): !Send & !Sync);
async_assert_fn!(tokio::time::Interval::tick(_): Send & Sync);
assert_value!(tokio::time::Interval: Unpin);
async_assert_fn!(tokio::time::sleep(Duration): !Unpin);
async_assert_fn!(tokio::time::sleep_until(Instant): !Unpin);
async_assert_fn!(tokio::time::timeout(Duration, BoxFuture<()>): !Unpin);
async_assert_fn!(tokio::time::timeout_at(Instant, BoxFuture<()>): !Unpin);
async_assert_fn!(tokio::time::Interval::tick(_): !Unpin);
async_assert_fn!(tokio::io::AsyncBufReadExt::read_until(&mut BoxAsyncRead, u8, &mut Vec<u8>): !Unpin);
async_assert_fn!(tokio::io::AsyncBufReadExt::read_line(&mut BoxAsyncRead, &mut String): !Unpin);
async_assert_fn!(tokio::io::AsyncReadExt::read(&mut BoxAsyncRead, &mut [u8]): !Unpin);