-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
time: remove Box
from Sleep
#3278
Conversation
Removes the box from `Sleep`, taking advantage of intrusive wakers. The `Sleep` future is now `!Unpin`. Closes #3267
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
@@ -317,15 +317,15 @@ async fn drop_after_reschedule_at_new_scheduled_time() { | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should have a test that asserts that Sleep
is !Unpin
(same for other types that contain pinned Sleep
s).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Such a test can easily be constructed using the macros in tokio/tokio/tests/async_send_sync.rs
.
Removes the box from
Sleep
, taking advantage of intrusive wakers. TheSleep
future is now!Unpin
.Interval
boxes theSleep
internally. The box is reused across polls which amortized the allocation. It makes the type a bit easier to use. Implementing an allocation-freeInterval
is fairly trivial usingasync-stream
and callingsleep()
.Most of the PR is updating code to handle
!Unpin
sleep.Closes #3267