diff --git a/actix-rt/Cargo.toml b/actix-rt/Cargo.toml index 10eac079..356c1f09 100644 --- a/actix-rt/Cargo.toml +++ b/actix-rt/Cargo.toml @@ -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] diff --git a/actix-rt/src/lib.rs b/actix-rt/src/lib.rs index 23dd01e8..22002b8f 100644 --- a/actix-rt/src/lib.rs +++ b/actix-rt/src/lib.rs @@ -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). diff --git a/actix-rt/src/runtime.rs b/actix-rt/src/runtime.rs index 557dfcfe..227977fc 100644 --- a/actix-rt/src/runtime.rs +++ b/actix-rt/src/runtime.rs @@ -12,6 +12,7 @@ pub struct Runtime { rt: tokio::runtime::Runtime, } +#[cfg(feature = "net")] pub(crate) fn default_tokio_runtime() -> io::Result { tokio::runtime::Builder::new_current_thread() .enable_io() @@ -19,6 +20,14 @@ pub(crate) fn default_tokio_runtime() -> io::Result { .build() } +#[cfg(not(feature = "net"))] +pub(crate) fn default_tokio_runtime() -> io::Result { + 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)]