-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
rt: add Runtime::shutdown_timeout
#2186
Conversation
Provides an API for forcing a runtime to shutdown even if there are still running tasks.
/// | ||
/// This currently is never returned, but might at some point in the future. | ||
#[derive(Debug)] | ||
pub(crate) struct ParkError { |
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.
Reshuffling internal code. This used to be public, which is why ParkError
is opaque.
let mut shared = self.spawner.inner.shared.lock().unwrap(); | ||
|
||
if shared.shutdown { |
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.
The function can be called multiple times. First, by explicitly calling shutdown
then by the drop handler calling shutdown
. This prevents shutting down twice.
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.
Might be good if there was a comment in the code stating that, as well as on the PR?
@carllerche looks like rustfmt still needs to be run? |
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.
this looks good to me — i commented on a few minor style nits & a little docs proofreading, but the change seems good!
let mut shared = self.spawner.inner.shared.lock().unwrap(); | ||
|
||
if shared.shutdown { |
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.
Might be good if there was a comment in the code stating that, as well as on the PR?
use crate::park::{CachedParkThread, Park}; | ||
use std::pin::Pin; | ||
use std::task::Context; | ||
use std::task::Poll::Ready; |
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.
minor style nit: some of these imports are now used by both block_on
and block_on_timeout
, should they be moved out of the individual functions?
Co-Authored-By: Eliza Weisman <eliza@buoyant.io>
Co-Authored-By: Eliza Weisman <eliza@buoyant.io>
Co-Authored-By: Eliza Weisman <eliza@buoyant.io>
Provides an API for forcing a runtime to shutdown even if there are
still running tasks.
Fixes #1923