-
Notifications
You must be signed in to change notification settings - Fork 336
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
Update async.md #739
Update async.md #739
Conversation
Fixes an edge case bug in the Delay implementation wherein the waker could be awoken after having returned `Poll::Ready` if the Delay was short enough (e.g. `0`).
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.
Waking the waker after returning Poll::Ready
is not actually incorrect. Spurious wakeups are always allowed.
Still, I don't mind this change.
There's a compilation error:
|
Fixes return type
Oops my bad, see the latest commit.
Interesting. In that case there may technically be a bug in the Mini Tokio implementation itself, at least the one I pieced together from the tutorial (which is admittedly substantively different from the full codebase the tutorial links to). When I run it with Delay set to $ RUST_BACKTRACE=1 cargo run
Finished dev [unoptimized + debuginfo] target(s) in 0.01s
Running `target/debug/mini_tokio`
Running mini_tokio...
delay 0 started!
delay 0 completed; out = "done"
thread 'main' panicked at src/main.rs:9:22:
`async fn` resumed after completion
stack backtrace:
0: rust_begin_unwind
at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/panicking.rs:595:5
1: core::panicking::panic_fmt
at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/core/src/panicking.rs:67:14
2: core::panicking::panic
at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/core/src/panicking.rs:117:5
3: mini_tokio::main::{{closure}}
at ./src/main.rs:9:22
4: mini_tokio::Task::poll
at ./src/lib.rs:125:17
5: mini_tokio::MiniTokio::run
at ./src/lib.rs:157:13
6: mini_tokio::main
at ./src/main.rs:21:5
7: core::ops::function::FnOnce::call_once
at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. |
Ah, yes, that's very possible. |
Fixes an edge case bug in the Delay implementation wherein the waker could be awoken after having returned
Poll::Ready
if the Delay was short enough (e.g.0
).