rt: add Runtime::shutdown_timeout (#2186)

Provides an API for forcing a runtime to shutdown even if there are
still running tasks.
This commit is contained in:
Carl Lerche
2020-01-29 12:00:40 -08:00
committed by GitHub
parent 560d0fa548
commit 9d6b99494b
7 changed files with 132 additions and 14 deletions
+17
View File
@@ -709,6 +709,23 @@ rt_test! {
}
}
#[test]
fn shutdown_timeout() {
let (tx, rx) = oneshot::channel();
let mut runtime = rt();
runtime.block_on(async move {
task::spawn_blocking(move || {
tx.send(()).unwrap();
thread::sleep(Duration::from_secs(10_000));
});
rx.await.unwrap();
});
runtime.shutdown_timeout(Duration::from_millis(100));
}
#[test]
fn runtime_in_thread_local() {
use std::cell::RefCell;