Skip to content

Conversation

@kleimkuhler
Copy link
Contributor

Motivation

Similar to #1666, it is no longer necessary to lazily register delays with the
executions default timer. All delays are expected to be created from within a
runtime, and should panic if not done so.

Solution

tokio::time now assumes there to be a CURRENT_TIMER set when creating a
delay; this can be assumed if called within a tokio runtime. If there is no
current timer, the application will panic with a "no current timer" message.

Follow-up

Similar to #1666, HandlePriv can probably be removed, but this mainly prepares
for 0.2 API changes. Because it is not in the public API, this can be done in a
following change.

Signed-off-by: Kevin Leimkuhler [email protected]

@kleimkuhler kleimkuhler self-assigned this Nov 20, 2019
Copy link
Member

@carllerche carllerche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great. One smallish request re: reverting a mostly unrelated change.

pub(crate) fn set_default(handle: &Handle) -> DefaultGuard<'_> {
CURRENT_TIMER.with(|current| {
let mut current = current.borrow_mut();
let prev = current.take();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be reverted and punted to a separate discussion. I was working on allowing re-entry (and I think some tests need it). Re-entry is needed since there are no more APIs that take handles, so it is the only way to use a custom timer.

Signed-off-by: Kevin Leimkuhler <[email protected]>
Signed-off-by: Kevin Leimkuhler <[email protected]>
@kleimkuhler kleimkuhler force-pushed the kleimkuhler/eager-timer-registration branch from e505717 to 98b102a Compare November 20, 2019 20:02
Copy link
Member

@carllerche carllerche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great 👍

@carllerche carllerche merged commit 3e643c7 into tokio-rs:master Nov 20, 2019
@kleimkuhler kleimkuhler deleted the kleimkuhler/eager-timer-registration branch November 20, 2019 21:55
kleimkuhler added a commit that referenced this pull request Dec 5, 2019
## Motivation

#1800 removed the lazy binding of `Delay`s to timers. With the removal of the
logic required for that, `HandlePriv` is no longer needed. This PR removes the
use of `HandlePriv`.

A `TODO` was also removed that would panic if when registering a new `Delay`
the current timer handle was full. That has been fixed to now immediately
transition that `Delay` to an error state that can be handled in a similar way
to other error states.

Signed-off-by: Kevin Leimkuhler <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants