mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-24 00:00:11 +02:00
Make tokio::run panic if called from inside tokio::run (#646)
This is implemented by creating an `Enter` instance from within `run`. This patch also introduces `Enter::block_on`. Fixes #504
This commit is contained in:
committed by
Carl Lerche
parent
85f8522536
commit
98d23b8b29
+4
-1
@@ -125,6 +125,7 @@ use reactor::{Background, Handle};
|
||||
|
||||
use std::io;
|
||||
|
||||
use tokio_executor::enter;
|
||||
use tokio_threadpool as threadpool;
|
||||
|
||||
use futures;
|
||||
@@ -210,7 +211,9 @@ where F: Future<Item = (), Error = ()> + Send + 'static,
|
||||
{
|
||||
let mut runtime = Runtime::new().unwrap();
|
||||
runtime.spawn(future);
|
||||
runtime.shutdown_on_idle().wait().unwrap();
|
||||
enter().expect("nested tokio::run")
|
||||
.block_on(runtime.shutdown_on_idle())
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
impl Runtime {
|
||||
|
||||
Reference in New Issue
Block a user