1
0
mirror of https://github.com/fafhrd91/actix-net synced 2025-08-25 18:16:03 +02:00

new_async -> run_in_executor and return future directly + builder cleanup

This commit is contained in:
George Hahn
2019-06-05 12:36:04 -05:00
parent c4f05e033f
commit 9e61f62871
2 changed files with 31 additions and 31 deletions

View File

@@ -2,11 +2,12 @@ use std::cell::RefCell;
use std::io;
use std::sync::atomic::{AtomicUsize, Ordering};
use tokio_current_thread::Handle;
use futures::sync::mpsc::UnboundedSender;
use futures::Future;
use tokio_current_thread::Handle;
use crate::arbiter::{Arbiter, SystemCommand};
use crate::builder::{Builder, SystemRunner, AsyncSystemRunner};
use crate::builder::{AsyncSystemRunner, Builder, SystemRunner};
static SYSTEM_COUNT: AtomicUsize = AtomicUsize::new(0);
@@ -60,8 +61,14 @@ impl System {
/// Create new system using provided CurrentThread Handle.
///
/// This method panics if it can not spawn system arbiter
pub fn new_async<T: Into<String>>(name: T, executor: Handle) -> AsyncSystemRunner {
Self::builder().name(name).build_async(executor)
pub fn run_in_executor<T: Into<String>>(
name: T,
executor: Handle,
) -> Box<Future<Item = (), Error = io::Error> + Send + 'static> {
Self::builder()
.name(name)
.build_async(executor)
.run_nonblocking()
}
/// Get current running system.