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

Delay::reset(0) should cause the delay to poll as Ready immediately #56

Open
Lucretiel opened this issue Feb 21, 2020 · 3 comments
Open
Assignees

Comments

@Lucretiel
Copy link

Lucretiel commented Feb 21, 2020

Currently, the following pesudocode:

let delay = Delay::new(Duration::from_secs(10));
thread::sleep(5);
delay.reset(Duration::from_secs(0));
assert_eq!(delay.poll_unpin(...), Poll::Ready(()));

Will spuriously fail on line 4, because resetting the Delay to 0 doesn't guarantee that it's immediately ready. While this makes sense if the 0-duration timer is unconditionally scheduled onto the thread, I found it a bit surprising; could a guarantee be established that this code passes?

@yoshuawuyts
Copy link
Contributor

@Lucretiel Thanks for opening this issue. I think what you're proposing sounds reasonable!. If you'd be willing to write a patch and a test for it, I'd be happy to review + merge!

@Lucretiel
Copy link
Author

Sure, I'll look into it! Can you assign this bug to me so it shows up on my dashboard?

@Lucretiel
Copy link
Author

Unfortunately this ended up being nontrivial; I wasn't confident enough in how the bit flags were being manipulated to implement this. I'll leave the issue open but right now I'm not going to be the one to implement it.

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

No branches or pull requests

2 participants