mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-29 00:00:11 +02:00
runtime: merge multi & single threaded runtimes (#1716)
Simplify Tokio's runtime construct by combining both Runtime variants into a single type. The execution style can be controlled by a configuration setting on `Builder`. The implication of this change is that there is no longer any way to spawn `!Send` futures. This, however, is a temporary limitation. A different strategy will be employed for supporting `!Send` futures. Included in this patch is a rework of `task::JoinHandle` to support using this type from both the thread-pool and current-thread executors.
This commit is contained in:
+4
-10
@@ -26,15 +26,9 @@ pub mod task;
|
||||
///
|
||||
/// [runtime-block-on]: https://docs.rs/tokio/0.2.0-alpha.2/tokio/runtime/current_thread/struct.Runtime.html#method.block_on
|
||||
pub fn block_on<F: std::future::Future>(future: F) -> F::Output {
|
||||
let mut rt = tokio::runtime::current_thread::Runtime::new().unwrap();
|
||||
use tokio::runtime;
|
||||
|
||||
let mut rt = runtime::Builder::new().current_thread().build().unwrap();
|
||||
|
||||
rt.block_on(future)
|
||||
}
|
||||
|
||||
/*
|
||||
#[doc(hidden)]
|
||||
pub mod codegen {
|
||||
pub mod futures {
|
||||
pub use futures::*;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user