summaryrefslogtreecommitdiffstats
path: root/tokio/tests/rt_common.rs
diff options
context:
space:
mode:
authorCarl Lerche <me@carllerche.com>2020-01-29 12:00:40 -0800
committerGitHub <noreply@github.com>2020-01-29 12:00:40 -0800
commit9d6b99494b72e79b4afba5073a9ebef5bbbeca8a (patch)
tree8804efeaec910a7881c63ff7723340d8993f23de /tokio/tests/rt_common.rs
parent560d0fa548314e223601ed83429daf237d72afbd (diff)
rt: add `Runtime::shutdown_timeout` (#2186)
Provides an API for forcing a runtime to shutdown even if there are still running tasks.
Diffstat (limited to 'tokio/tests/rt_common.rs')
-rw-r--r--tokio/tests/rt_common.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/tokio/tests/rt_common.rs b/tokio/tests/rt_common.rs
index 31edd10a..64dd3680 100644
--- a/tokio/tests/rt_common.rs
+++ b/tokio/tests/rt_common.rs
@@ -710,6 +710,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;
use std::thread;