-
Notifications
You must be signed in to change notification settings - Fork 340
feat: use smol as runtime #757
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 25 commits
690ab16
1308fbd
fc9ee0d
e082634
75ab721
b96afc4
f5fa0d7
ab9d655
fd6ae40
10c8b9a
0a7a52a
228cc59
3161a4e
2cd2ba3
e4df140
804a52b
48dd683
280b1a4
7a9afbd
1a6d4f6
9253261
e092846
26f62aa
1214bc2
faea222
27c605b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ version = "1.5.0" | |
authors = [ | ||
"Stjepan Glavina <[email protected]>", | ||
"Yoshua Wuyts <[email protected]>", | ||
"Friedel Ziegelmayer <[email protected]>", | ||
"Contributors to async-std", | ||
] | ||
edition = "2018" | ||
|
@@ -24,19 +25,13 @@ rustdoc-args = ["--cfg", "feature=\"docs\""] | |
default = [ | ||
"std", | ||
"async-task", | ||
"crossbeam-channel", | ||
"crossbeam-deque", | ||
"crossbeam-queue", | ||
"futures-timer", | ||
"kv-log-macro", | ||
"log", | ||
"mio", | ||
"mio-uds", | ||
"num_cpus", | ||
"pin-project-lite", | ||
] | ||
docs = ["attributes", "unstable", "default"] | ||
unstable = ["std", "broadcaster", "futures-timer"] | ||
unstable = ["std", "broadcaster"] | ||
attributes = ["async-attributes"] | ||
std = [ | ||
"alloc", | ||
|
@@ -47,6 +42,10 @@ std = [ | |
"once_cell", | ||
"pin-utils", | ||
"slab", | ||
"smol", | ||
"wasm-timer", | ||
"wasm-bindgen-futures", | ||
"futures-channel", | ||
] | ||
alloc = [ | ||
"futures-core/alloc", | ||
|
@@ -55,32 +54,38 @@ alloc = [ | |
|
||
[dependencies] | ||
async-attributes = { version = "1.1.1", optional = true } | ||
async-task = { version = "1.3.1", optional = true } | ||
async-task = { version = "3.0.0", optional = true } | ||
broadcaster = { version = "1.0.0", optional = true } | ||
crossbeam-channel = { version = "0.4.2", optional = true } | ||
crossbeam-deque = { version = "0.7.3", optional = true } | ||
crossbeam-queue = { version = "0.2.0", optional = true } | ||
crossbeam-utils = { version = "0.7.2", optional = true } | ||
futures-core = { version = "0.3.4", optional = true, default-features = false } | ||
futures-io = { version = "0.3.4", optional = true } | ||
futures-timer = { version = "3.0.2", optional = true } | ||
kv-log-macro = { version = "1.0.4", optional = true } | ||
log = { version = "0.4.8", features = ["kv_unstable"], optional = true } | ||
memchr = { version = "2.3.3", optional = true } | ||
mio = { version = "0.6.19", optional = true } | ||
mio-uds = { version = "0.6.7", optional = true } | ||
num_cpus = { version = "1.12.0", optional = true } | ||
once_cell = { version = "1.3.1", optional = true } | ||
pin-project-lite = { version = "0.1.4", optional = true } | ||
pin-utils = { version = "0.1.0-alpha.4", optional = true } | ||
slab = { version = "0.4.2", optional = true } | ||
|
||
[target.'cfg(not(target_os = "unknown"))'.dependencies] | ||
smol = { version = "0.1.1", optional = true } | ||
|
||
[target.'cfg(target_arch = "wasm32")'.dependencies] | ||
wasm-timer = { version = "0.2.4", optional = true } | ||
wasm-bindgen-futures = { version = "0.4.10", optional = true } | ||
futures-channel = { version = "0.3.4", optional = true } | ||
|
||
[target.'cfg(target_arch = "wasm32")'.dev-dependencies] | ||
wasm-bindgen-test = "0.3.10" | ||
Comment on lines
+79
to
+80
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is so exciting! |
||
|
||
[dev-dependencies] | ||
femme = "1.3.0" | ||
rand = "0.7.3" | ||
surf = "1.0.3" | ||
tempdir = "0.3.7" | ||
futures = "0.3.4" | ||
rand_xorshift = "0.2.0" | ||
|
||
[[test]] | ||
name = "stream" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,9 +17,9 @@ use std::mem; | |
|
||
use crate::io::IoSliceMut; | ||
|
||
pub use take::Take; | ||
pub use bytes::Bytes; | ||
pub use chain::Chain; | ||
pub use take::Take; | ||
|
||
extension_trait! { | ||
use std::pin::Pin; | ||
|
@@ -477,13 +477,13 @@ unsafe fn initialize<R: futures_io::AsyncRead>(_reader: &R, buf: &mut [u8]) { | |
std::ptr::write_bytes(buf.as_mut_ptr(), 0, buf.len()) | ||
} | ||
|
||
#[cfg(test)] | ||
#[cfg(all(test, not(target_os = "unknown")))] | ||
mod tests { | ||
use crate::io; | ||
use crate::prelude::*; | ||
|
||
#[test] | ||
fn test_read_by_ref() -> io::Result<()> { | ||
fn test_read_by_ref() { | ||
crate::task::block_on(async { | ||
let mut f = io::Cursor::new(vec![0u8, 1, 2, 3, 4, 5, 6, 7, 8]); | ||
let mut buffer = Vec::new(); | ||
|
@@ -493,14 +493,13 @@ mod tests { | |
let reference = f.by_ref(); | ||
|
||
// read at most 5 bytes | ||
assert_eq!(reference.take(5).read_to_end(&mut buffer).await?, 5); | ||
assert_eq!(reference.take(5).read_to_end(&mut buffer).await.unwrap(), 5); | ||
assert_eq!(&buffer, &[0, 1, 2, 3, 4]) | ||
} // drop our &mut reference so we can use f again | ||
|
||
// original file still usable, read the rest | ||
assert_eq!(f.read_to_end(&mut other_buffer).await?, 4); | ||
assert_eq!(f.read_to_end(&mut other_buffer).await.unwrap(), 4); | ||
assert_eq!(&other_buffer, &[5, 6, 7, 8]); | ||
Ok(()) | ||
}) | ||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why was There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. because |
||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally we could use our own channels in this context, which already work. But for the purpose of this PR this seems fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They didn't quite do what I needed, we can improve on that later on.