Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f9c8974

Browse files
Merge pull request #836 from Keruspe/multitask
2 parents 820acc1 + abc2929 commit f9c8974

File tree

17 files changed

+139
-46
lines changed

17 files changed

+139
-46
lines changed

‎.github/workflows/ci.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,12 @@ jobs:
8686
command: check
8787
args: --features attributes
8888

89+
- name: build unstable only
90+
uses: actions-rs/cargo@v1
91+
with:
92+
command: build
93+
args: --no-default-features --features unstable
94+
8995
- name: tests
9096
uses: actions-rs/cargo@v1
9197
with:

‎Cargo.toml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,15 @@ rustdoc-args = ["--cfg", "feature=\"docs\""]
2424
[features]
2525
default = [
2626
"std",
27+
"async-executor",
28+
"async-io",
2729
"async-task",
30+
"blocking",
31+
"futures-lite",
2832
"kv-log-macro",
2933
"log",
3034
"num_cpus",
3135
"pin-project-lite",
32-
"smol",
3336
]
3437
docs = ["attributes", "unstable", "default"]
3538
unstable = [
@@ -54,7 +57,7 @@ alloc = [
5457
"futures-core/alloc",
5558
"pin-project-lite",
5659
]
57-
tokio02 = ["smol/tokio02"]
60+
tokio02 = ["tokio"]
5861

5962
[dependencies]
6063
async-attributes = { version = "1.1.1", optional = true }
@@ -77,7 +80,10 @@ futures-timer = { version = "3.0.2", optional = true }
7780
surf = { version = "1.0.3", optional = true }
7881

7982
[target.'cfg(not(target_os = "unknown"))'.dependencies]
80-
smol = { version = "0.1.17", optional = true }
83+
async-executor = { version = "0.1.1", features = ["async-io"], optional = true }
84+
async-io = { version = "0.1.5", optional = true }
85+
blocking = { version = "0.5.0", optional = true }
86+
futures-lite = { version = "0.1.8", optional = true }
8187

8288
[target.'cfg(target_arch = "wasm32")'.dependencies]
8389
futures-timer = { version = "3.0.2", optional = true, features = ["wasm-bindgen"] }
@@ -87,6 +93,12 @@ futures-channel = { version = "0.3.4", optional = true }
8793
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
8894
wasm-bindgen-test = "0.3.10"
8995

96+
[dependencies.tokio]
97+
version = "0.2"
98+
default-features = false
99+
features = ["rt-threaded"]
100+
optional = true
101+
90102
[dev-dependencies]
91103
femme = "1.3.0"
92104
rand = "0.7.3"

‎src/fs/file.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ impl Drop for File {
315315
// non-blocking fashion, but our only other option here is losing data remaining in the
316316
// write cache. Good task schedulers should be resilient to occasional blocking hiccups in
317317
// file destructors so we don't expect this to be a common problem in practice.
318-
let _ = smol::block_on(self.flush());
318+
let _ = futures_lite::future::block_on(self.flush());
319319
}
320320
}
321321

‎src/net/tcp/listener.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::future::Future;
22
use std::net::SocketAddr;
33
use std::pin::Pin;
44

5-
use smol::Async;
5+
use async_io::Async;
66

77
use crate::io;
88
use crate::net::{TcpStream, ToSocketAddrs};
@@ -81,7 +81,7 @@ impl TcpListener {
8181
let addrs = addrs.to_socket_addrs().await?;
8282

8383
for addr in addrs {
84-
match Async::<std::net::TcpListener>::bind(&addr) {
84+
match Async::<std::net::TcpListener>::bind(addr) {
8585
Ok(listener) => {
8686
return Ok(TcpListener { watcher: listener });
8787
}
@@ -227,7 +227,7 @@ cfg_unix! {
227227

228228
impl IntoRawFd for TcpListener {
229229
fn into_raw_fd(self) -> RawFd {
230-
self.watcher.into_raw_fd()
230+
self.watcher.into_inner().unwrap().into_raw_fd()
231231
}
232232
}
233233
}
@@ -251,7 +251,7 @@ cfg_windows! {
251251

252252
impl IntoRawSocket for TcpListener {
253253
fn into_raw_socket(self) -> RawSocket {
254-
self.watcher.into_raw_socket()
254+
self.watcher.into_inner().unwrap().into_raw_socket()
255255
}
256256
}
257257
}

‎src/net/tcp/stream.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::io::{IoSlice, IoSliceMut};
22
use std::net::SocketAddr;
33
use std::pin::Pin;
44

5-
use smol::Async;
5+
use async_io::Async;
66

77
use crate::io::{self, Read, Write};
88
use crate::net::ToSocketAddrs;
@@ -77,7 +77,7 @@ impl TcpStream {
7777
let addrs = addrs.to_socket_addrs().await?;
7878

7979
for addr in addrs {
80-
match Async::<std::net::TcpStream>::connect(&addr).await {
80+
match Async::<std::net::TcpStream>::connect(addr).await {
8181
Ok(stream) => {
8282
return Ok(TcpStream {
8383
watcher: Arc::new(stream),

‎src/net/udp/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::io;
22
use std::net::SocketAddr;
33
use std::net::{Ipv4Addr, Ipv6Addr};
44

5-
use smol::Async;
5+
use async_io::Async;
66

77
use crate::net::ToSocketAddrs;
88
use crate::utils::Context as _;
@@ -74,7 +74,7 @@ impl UdpSocket {
7474
let addrs = addrs.to_socket_addrs().await?;
7575

7676
for addr in addrs {
77-
match Async::<std::net::UdpSocket>::bind(&addr) {
77+
match Async::<std::net::UdpSocket>::bind(addr) {
7878
Ok(socket) => {
7979
return Ok(UdpSocket { watcher: socket });
8080
}
@@ -506,7 +506,7 @@ cfg_unix! {
506506

507507
impl IntoRawFd for UdpSocket {
508508
fn into_raw_fd(self) -> RawFd {
509-
self.watcher.into_raw_fd()
509+
self.watcher.into_inner().unwrap().into_raw_fd()
510510
}
511511
}
512512
}
@@ -530,7 +530,7 @@ cfg_windows! {
530530

531531
impl IntoRawSocket for UdpSocket {
532532
fn into_raw_socket(self) -> RawSocket {
533-
self.watcher.into_raw_socket()
533+
self.watcher.into_inner().unwrap().into_raw_socket()
534534
}
535535
}
536536
}

‎src/os/unix/net/datagram.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::fmt;
44
use std::net::Shutdown;
55
use std::os::unix::net::UnixDatagram as StdUnixDatagram;
66

7-
use smol::Async;
7+
use async_io::Async;
88

99
use super::SocketAddr;
1010
use crate::io;
@@ -335,6 +335,6 @@ impl FromRawFd for UnixDatagram {
335335

336336
impl IntoRawFd for UnixDatagram {
337337
fn into_raw_fd(self) -> RawFd {
338-
self.watcher.into_raw_fd()
338+
self.watcher.into_inner().unwrap().into_raw_fd()
339339
}
340340
}

‎src/os/unix/net/listener.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::future::Future;
55
use std::os::unix::net::UnixListener as StdUnixListener;
66
use std::pin::Pin;
77

8-
use smol::Async;
8+
use async_io::Async;
99

1010
use super::SocketAddr;
1111
use super::UnixStream;
@@ -217,6 +217,6 @@ impl FromRawFd for UnixListener {
217217

218218
impl IntoRawFd for UnixListener {
219219
fn into_raw_fd(self) -> RawFd {
220-
self.watcher.into_raw_fd()
220+
self.watcher.into_inner().unwrap().into_raw_fd()
221221
}
222222
}

‎src/os/unix/net/stream.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::net::Shutdown;
55
use std::os::unix::net::UnixStream as StdUnixStream;
66
use std::pin::Pin;
77

8-
use smol::Async;
8+
use async_io::Async;
99

1010
use super::SocketAddr;
1111
use crate::io::{self, Read, Write};

‎src/os/windows/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ cfg_std! {
55
}
66

77
cfg_unstable! {
8+
#[cfg(feature = "default")]
89
pub mod fs;
910
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /