Skip to content
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

Merged
merged 5 commits into from Dec 17, 2020
Merged

time: remove Box from Sleep #3278

merged 5 commits into from Dec 17, 2020

Conversation

carllerche
Copy link
Member

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

Interval boxes the Sleep internally. The box is reused across polls which amortized the allocation. It makes the type a bit easier to use. Implementing an allocation-free Interval is fairly trivial using async-stream and calling sleep().

Most of the PR is updating code to handle !Unpin sleep.

Closes #3267

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

Closes #3267
@carllerche carllerche added this to the v1.0 milestone Dec 15, 2020
@Darksonn Darksonn added A-tokio Area: The main tokio crate M-time Module: tokio/time labels Dec 15, 2020
Copy link
Contributor

@Darksonn Darksonn left a 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!

tokio-test/src/io.rs Outdated Show resolved Hide resolved
@@ -317,15 +317,15 @@ async fn drop_after_reschedule_at_new_scheduled_time() {

Copy link
Contributor

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 Sleeps).

Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate M-time Module: tokio/time
Projects
None yet
Development

Successfully merging this pull request may close these issues.

time: Sleep should be !Unpin
3 participants