diff --git a/actix-rt/Cargo.toml b/actix-rt/Cargo.toml index 70ab0af8..d4d169c8 100644 --- a/actix-rt/Cargo.toml +++ b/actix-rt/Cargo.toml @@ -28,7 +28,9 @@ actix-macros = { version = "0.2.0", optional = true } futures-core = { version = "0.3", default-features = false } tokio = { version = "1.3", features = ["rt", "net", "parking_lot", "signal", "sync", "time"] } -tokio-uring = { git = "https://github.com/tokio-rs/tokio-uring.git", optional = true } + +[target."cfg(target_os = \"linux\")".dependencies] +tokio-uring = { version = "0.1", optional = true } [dev-dependencies] tokio = { version = "1.2", features = ["full"] } diff --git a/actix-rt/src/arbiter.rs b/actix-rt/src/arbiter.rs index 8d51a7f2..fed7eddb 100644 --- a/actix-rt/src/arbiter.rs +++ b/actix-rt/src/arbiter.rs @@ -91,7 +91,7 @@ pub struct Arbiter { } impl Arbiter { - #[cfg(not(feature = "io-uring"))] + #[cfg(any(not(target_os = "linux"), not(feature = "io-uring")))] /// Spawn a new Arbiter thread and start its event loop. /// /// # Panics @@ -104,7 +104,7 @@ impl Arbiter { }) } - #[cfg(not(feature = "io-uring"))] + #[cfg(any(not(target_os = "linux"), not(feature = "io-uring")))] /// Spawn a new Arbiter using the [Tokio Runtime](tokio-runtime) returned from a closure. /// /// [tokio-runtime]: tokio::runtime::Runtime @@ -159,7 +159,7 @@ impl Arbiter { Arbiter { tx, thread_handle } } - #[cfg(feature = "io-uring")] + #[cfg(all(target_os = "linux", feature = "io-uring"))] /// Spawn a new Arbiter thread and start its event loop with `tokio-uring` runtime. /// /// # Panics diff --git a/actix-rt/tests/tests.rs b/actix-rt/tests/tests.rs index e94cbd00..974a5be8 100644 --- a/actix-rt/tests/tests.rs +++ b/actix-rt/tests/tests.rs @@ -302,7 +302,7 @@ fn try_current_with_system() { System::new().block_on(async { assert!(System::try_current().is_some()) }); } -#[cfg(feature = "io-uring")] +#[cfg(all(target_os = "linux", feature = "io-uring"))] #[test] fn tokio_uring_arbiter() { let system = System::new(); diff --git a/actix-server/src/worker.rs b/actix-server/src/worker.rs index 3a2da590..357a731c 100644 --- a/actix-server/src/worker.rs +++ b/actix-server/src/worker.rs @@ -280,7 +280,7 @@ impl ServerWorker { let counter_clone = counter.clone(); // every worker runs in it's own arbiter. // use a custom tokio runtime builder to change the settings of runtime. - #[cfg(feature = "io-uring")] + #[cfg(all(target_os = "linux", feature = "io-uring"))] let arbiter = { // TODO: pass max blocking thread config when tokio-uring enable configuration // on building runtime. @@ -288,7 +288,7 @@ impl ServerWorker { Arbiter::new() }; - #[cfg(not(feature = "io-uring"))] + #[cfg(any(not(target_os = "linux"), not(feature = "io-uring")))] let arbiter = Arbiter::with_tokio_rt(move || { tokio::runtime::Builder::new_current_thread() .enable_all()