1 #![cfg(feature = "rt")]
2 #![warn(rust_2018_idioms)]
3 
4 use tokio::runtime::Builder;
5 use tokio::time::*;
6 use tokio_util::context::RuntimeExt;
7 
8 #[test]
tokio_context_with_another_runtime()9 fn tokio_context_with_another_runtime() {
10     let rt1 = Builder::new_multi_thread()
11         .worker_threads(1)
12         // no timer!
13         .build()
14         .unwrap();
15     let rt2 = Builder::new_multi_thread()
16         .worker_threads(1)
17         .enable_all()
18         .build()
19         .unwrap();
20 
21     // Without the `HandleExt.wrap()` there would be a panic because there is
22     // no timer running, since it would be referencing runtime r1.
23     let _ = rt1.block_on(rt2.wrap(async move { sleep(Duration::from_millis(2)).await }));
24 }
25