Skip to content

Commit 91a734b

Browse files
authored
Merge pull request #68 from Berrysoft/dev/linux-polling
Make polling available on Linux.
2 parents 22afe2f + 7b999bb commit 91a734b

File tree

4 files changed

+25
-8
lines changed

4 files changed

+25
-8
lines changed

Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ windows-sys = { version = "0.48", features = ["Win32_Security_Authorization"] }
7070

7171
# Linux specific dependencies
7272
[target.'cfg(target_os = "linux")'.dependencies]
73-
io-uring = "0.6"
73+
io-uring = { version = "0.6", optional = true }
74+
polling = { version = "3", optional = true }
7475
libc = "0.2"
7576

7677
# Other platform dependencies
@@ -79,7 +80,7 @@ polling = "3"
7980
libc = "0.2"
8081

8182
[features]
82-
default = ["runtime"]
83+
default = ["runtime", "io-uring"]
8384
runtime = ["dep:async-task", "dep:futures-util", "dep:smallvec"]
8485
event = ["runtime", "arrayvec"]
8586
signal = ["event"]

azure-pipelines.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- script: |
2121
rustup toolchain install nightly
2222
rustup +nightly target install $(target)
23-
cargo +nightly test --features=all,nightly --no-default-features --target $(target) -Z doctest-xcompile
23+
cargo +nightly test --features=all,nightly --target $(target) -Z doctest-xcompile
2424
displayName: TestNightly
2525
- script: |
2626
cargo test --features all --target $(target)
@@ -39,12 +39,20 @@ jobs:
3939
steps:
4040
- script: |
4141
rustup toolchain install nightly
42-
cargo +nightly test --features all,nightly --no-default-features
42+
cargo +nightly test --features all,nightly
4343
displayName: TestNightly
4444
- script: |
4545
cargo test --features all
4646
displayName: TestStable
4747
48+
- script: |
49+
rustup toolchain install nightly
50+
cargo +nightly test --features all,polling,nightly --no-default-features
51+
displayName: TestNightly-polling
52+
- script: |
53+
cargo test --features all,polling --no-default-features
54+
displayName: TestStable-polling
55+
4856
- job: Test_Mac
4957
strategy:
5058
matrix:
@@ -58,7 +66,7 @@ jobs:
5866
steps:
5967
- script: |
6068
rustup toolchain install nightly
61-
cargo +nightly test --features all,nightly --no-default-features
69+
cargo +nightly test --features all,nightly
6270
displayName: TestNightly
6371
- script: |
6472
cargo test --features all

src/driver/mod.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,30 @@
11
//! The platform-specified driver.
22
//! Some types differ by compilation target.
33
4+
#[cfg(all(
5+
target_os = "linux",
6+
not(feature = "io-uring"),
7+
not(feature = "polling")
8+
))]
9+
compile_error!("You must choose one of these features: [\"io-uring\", \"polling\"]");
10+
411
use std::{collections::VecDeque, io, time::Duration};
512

613
use slab::Slab;
714

815
use crate::BufResult;
16+
917
#[cfg(unix)]
1018
mod unix;
1119

1220
cfg_if::cfg_if! {
1321
if #[cfg(target_os = "windows")] {
1422
mod iocp;
1523
pub use iocp::*;
16-
} else if #[cfg(target_os = "linux")] {
24+
} else if #[cfg(all(target_os = "linux", feature = "io-uring"))] {
1725
mod iour;
1826
pub use iour::*;
19-
} else if #[cfg(unix)]{
27+
} else if #[cfg(unix)] {
2028
mod poll;
2129
pub use poll::*;
2230
}

src/net/socket.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ impl Socket {
5959
// non blocking socket when there is no connections in listen queue
6060
//
6161
// https://patchwork.kernel.org/project/linux-block/patch/[email protected]/#22949861
62-
#[cfg(all(unix, not(target_os = "linux")))]
62+
#[cfg(all(unix, not(all(target_os = "linux", feature = "io-uring"))))]
6363
socket.set_nonblocking(true)?;
6464
Ok(Self::from_socket2(socket))
6565
}

0 commit comments

Comments
 (0)