mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-09-06 00:00:10 +02:00
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user