1
0
mirror of https://github.com/fafhrd91/actix-net synced 2025-02-26 04:53:51 +01:00

remove hard dependency for tokio net and tokio signal

This commit is contained in:
Akos Vandra 2022-10-10 17:55:36 +02:00
parent c4a0f37d0c
commit 845b465f65
3 changed files with 16 additions and 4 deletions

View File

@ -19,15 +19,16 @@ name = "actix_rt"
path = "src/lib.rs"
[features]
default = ["macros"]
default = ["macros", "net"]
macros = ["actix-macros"]
io-uring = ["tokio-uring"]
net = ["tokio/net", "tokio/signal"]
[dependencies]
actix-macros = { version = "0.2.3", optional = true }
futures-core = { version = "0.3", default-features = false }
tokio = { version = "1.13.1", features = ["rt", "net", "parking_lot", "signal", "sync", "time"] }
tokio = { version = "1.13.1", features = ["rt", "parking_lot", "sync", "time"] }
# runtime for `io-uring` feature
[target.'cfg(target_os = "linux")'.dependencies]

View File

@ -69,17 +69,19 @@ pub use self::arbiter::{Arbiter, ArbiterHandle};
pub use self::runtime::Runtime;
pub use self::system::{System, SystemRunner};
#[cfg(feature = "net")]
pub mod signal {
//! Asynchronous signal handling (Tokio re-exports).
#[cfg(unix)]
pub mod unix {
//! Unix specific signals (Tokio re-exports).
pub use tokio::signal::unix::*;
// pub use tokio::signal::unix::*;
}
pub use tokio::signal::ctrl_c;
// pub use tokio::signal::ctrl_c;
}
#[cfg(feature = "net")]
pub mod net {
//! TCP/UDP/Unix bindings (mostly Tokio re-exports).

View File

@ -12,6 +12,7 @@ pub struct Runtime {
rt: tokio::runtime::Runtime,
}
#[cfg(feature = "net")]
pub(crate) fn default_tokio_runtime() -> io::Result<tokio::runtime::Runtime> {
tokio::runtime::Builder::new_current_thread()
.enable_io()
@ -19,6 +20,14 @@ pub(crate) fn default_tokio_runtime() -> io::Result<tokio::runtime::Runtime> {
.build()
}
#[cfg(not(feature = "net"))]
pub(crate) fn default_tokio_runtime() -> io::Result<tokio::runtime::Runtime> {
tokio::runtime::Builder::new_current_thread()
.enable_time()
.build()
}
impl Runtime {
/// Returns a new runtime initialized with default configuration values.
#[allow(clippy::new_ret_no_self)]