1
0
mirror of https://github.com/fafhrd91/actix-net synced 2025-06-28 02:59:01 +02:00

update to tokio 1.0 for actix-rt (#236)

This commit is contained in:
fakeshadow
2020-12-28 09:40:22 +08:00
committed by GitHub
parent ba44ea7d0b
commit 0c12930796
9 changed files with 49 additions and 61 deletions

View File

@ -18,10 +18,9 @@ impl Runtime {
#[allow(clippy::new_ret_no_self)]
/// Returns a new runtime initialized with default configuration values.
pub fn new() -> io::Result<Runtime> {
let rt = runtime::Builder::new()
let rt = runtime::Builder::new_current_thread()
.enable_io()
.enable_time()
.basic_scheduler()
.build()?;
Ok(Runtime {
@ -48,7 +47,7 @@ impl Runtime {
///
/// # fn dox() {
/// // Create the runtime
/// let mut rt = Runtime::new().unwrap();
/// let rt = Runtime::new().unwrap();
///
/// // Spawn a future onto the runtime
/// rt.spawn(future::lazy(|_| {
@ -86,10 +85,10 @@ impl Runtime {
///
/// The caller is responsible for ensuring that other spawned futures
/// complete execution by calling `block_on` or `run`.
pub fn block_on<F>(&mut self, f: F) -> F::Output
pub fn block_on<F>(&self, f: F) -> F::Output
where
F: Future,
{
self.local.block_on(&mut self.rt, f)
self.local.block_on(&self.rt, f)
}
}