Skip to content

Commit 276c8f3

Browse files
committed
tokio: use cfg-if to actually fix windows build
1 parent f6ac142 commit 276c8f3

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

Cargo.lock

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ tokio = ["dep:tokio", "dep:tokio-stream"]
2121

2222
[dependencies]
2323
async-trait = "^0.1.89"
24+
cfg-if = "^1.0"
2425
futures-core = "^0.3"
2526
futures-io = "^0.3"
2627

src/implementors/tokio.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
33
use crate::{AsyncIOHandle, Executor, IOHandle, Reactor, Runtime, RuntimeKit, Task, sys::IO};
44
use async_trait::async_trait;
5+
use cfg_if::cfg_if;
56
use futures_core::Stream;
67
use std::{
78
future::Future,
@@ -117,14 +118,16 @@ impl Reactor for Tokio {
117118
socket: IOHandle<H>,
118119
) -> io::Result<impl AsyncIOHandle + Send> {
119120
let _enter = self.handle().as_ref().map(|handle| handle.enter());
120-
if cfg!(unix) {
121-
Ok(Box::new(unix::AsyncFdWrapper(
122-
tokio::io::unix::AsyncFd::new(socket)?,
123-
)))
124-
} else {
125-
Err(io::Error::other(
126-
"Registering FD on tokio reactor is only supported on unix",
127-
))
121+
cfg_if! {
122+
if #[cfg(unix)] {
123+
Ok(Box::new(unix::AsyncFdWrapper(
124+
tokio::io::unix::AsyncFd::new(socket)?,
125+
)))
126+
} else {
127+
Err(io::Error::other(
128+
"Registering FD on tokio reactor is only supported on unix",
129+
))
130+
}
128131
}
129132
}
130133

0 commit comments

Comments
 (0)