Skip to content

Commit a722de1

Browse files
committed
Merge remote-tracking branch 'upstream/master' into 342-stream-throttle
2 parents 88cbf2c + 46c58b2 commit a722de1

40 files changed

+406
-464
lines changed

CHANGELOG.md

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,60 @@ and this project adheres to [Semantic Versioning](https://book.async.rs/overview
77

88
## [Unreleased]
99

10+
# [1.0.1] - 2019-11-12
11+
12+
[API Documentation](https://docs.rs/async-std/1.0.1/async-std)
13+
14+
We were seeing a regression in our fs performance, caused by too many
15+
long-running tasks. This patch fixes that regression by being more proactive
16+
about closing down idle threads.
17+
18+
## Changes
19+
20+
- Improved thread startup/shutdown algorithm in `task::spawn_blocking`.
21+
- Fixed a typo in the tutorial.
22+
23+
# [1.0.0] - 2019-11-11
24+
25+
[API Documentation](https://docs.rs/async-std/1.0.0/async-std)
26+
27+
This release marks the `1.0.0` release of async-std; a major milestone for our
28+
development. This release itself mostly includes quality of life improvements
29+
for all of modules, including more consistent API bounds for a lot of our
30+
submodules.
31+
32+
The biggest change is that we're now using the full semver range,
33+
`major.minor.patch`, and any breaking changes to our "stable" APIs will require
34+
an update of the `major` number.
35+
36+
We're excited we've hit this milestone together with you all. Thank you!
37+
38+
## Added
39+
40+
- Added `Future::join` as "unstable", replacing `future::join!`.
41+
- Added `Future::try_join` as "unstable", replacing `future::try_join!`.
42+
- Enabled `stable` and `beta` channel testing on CI.
43+
- Implemented `FromIterator` and `Extend` for `PathBuf`.
44+
- Implemented `FromStream` for `PathBuf`.
45+
- Loosened the trait bounds of `io::copy` on "unstable".
46+
47+
## Changed
48+
49+
- Added a `Sync` bound to `RwLock`, resolving a memory safety issue.
50+
- Fixed a bug in `Stream::take_while` where it could continue after it should've
51+
ended.
52+
- Fixed a bug where our `attributes` Cargo feature wasn't working as intended.
53+
- Improved documentation of `Stream::merge`, documenting ordering guarantees.
54+
- Update doc imports in examples to prefer async-std's types.
55+
- Various quality of life improvements to the `future` submodule.
56+
- Various quality of life improvements to the `path` submodule.
57+
- Various quality of life improvements to the `stream` submodule.
58+
59+
## Removed
60+
61+
- Removed `future::join!` in favor of `Future::join`.
62+
- Removed `future::try_join!` in favor of `Future::try_join`.
63+
1064
# [0.99.12] - 2019-11-07
1165

1266
[API Documentation](https://docs.rs/async-std/0.99.12/async-std)
@@ -388,8 +442,11 @@ task::blocking(async {
388442

389443
- Initial beta release
390444

391-
[Unreleased]: https://github.com/async-rs/async-std/compare/v0.99.11...HEAD
392-
[0.99.10]: https://github.com/async-rs/async-std/compare/v0.99.10...v0.99.11
445+
[Unreleased]: https://github.com/async-rs/async-std/compare/v1.0.1...HEAD
446+
[1.0.1]: https://github.com/async-rs/async-std/compare/v1.0.0...v1.0.1
447+
[1.0.0]: https://github.com/async-rs/async-std/compare/v0.99.12...v1.0.0
448+
[0.99.12]: https://github.com/async-rs/async-std/compare/v0.99.11...v0.99.12
449+
[0.99.11]: https://github.com/async-rs/async-std/compare/v0.99.10...v0.99.11
393450
[0.99.10]: https://github.com/async-rs/async-std/compare/v0.99.9...v0.99.10
394451
[0.99.9]: https://github.com/async-rs/async-std/compare/v0.99.8...v0.99.9
395452
[0.99.8]: https://github.com/async-rs/async-std/compare/v0.99.7...v0.99.8

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "async-std"
3-
version = "0.99.12"
3+
version = "1.0.1"
44
authors = [
55
"Stjepan Glavina <[email protected]>",
66
"Yoshua Wuyts <[email protected]>",

docs/src/tutorial/specification.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,6 @@ Add the following lines to `Cargo.toml`:
5050

5151
```toml
5252
[dependencies]
53-
futures-preview = { version = "0.3.0-alpha.19", features = [ "async-await" ] }
54-
async-std = "0.99"
53+
futures = "0.3.0"
54+
async-std = "1.0.0"
5555
```

src/io/mod.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
//! [`File`]s:
2020
//!
2121
//! ```no_run
22-
//! use async_std::prelude::*;
2322
//! use async_std::fs::File;
23+
//! use async_std::prelude::*;
2424
//!
2525
//! # fn main() -> std::io::Result<()> { async_std::task::block_on(async {
2626
//! #
@@ -47,9 +47,9 @@
4747
//! coming from:
4848
//!
4949
//! ```no_run
50-
//! use async_std::io::prelude::*;
51-
//! use async_std::io::SeekFrom;
5250
//! use async_std::fs::File;
51+
//! use async_std::io::SeekFrom;
52+
//! use async_std::prelude::*;
5353
//!
5454
//! # fn main() -> std::io::Result<()> { async_std::task::block_on(async {
5555
//! #
@@ -82,9 +82,9 @@
8282
//! methods to any reader:
8383
//!
8484
//! ```no_run
85-
//! use async_std::io::prelude::*;
86-
//! use async_std::io::BufReader;
8785
//! use async_std::fs::File;
86+
//! use async_std::io::BufReader;
87+
//! use async_std::prelude::*;
8888
//!
8989
//! # fn main() -> std::io::Result<()> { async_std::task::block_on(async {
9090
//! #
@@ -104,9 +104,9 @@
104104
//! to [`write`][`Write::write`]:
105105
//!
106106
//! ```no_run
107-
//! use async_std::io::prelude::*;
108-
//! use async_std::io::BufWriter;
109107
//! use async_std::fs::File;
108+
//! use async_std::io::BufWriter;
109+
//! use async_std::io::prelude::*;
110110
//!
111111
//! # fn main() -> std::io::Result<()> { async_std::task::block_on(async {
112112
//! #
@@ -179,9 +179,9 @@
179179
//! lines:
180180
//!
181181
//! ```no_run
182-
//! use async_std::prelude::*;
183-
//! use async_std::io::BufReader;
184182
//! use async_std::fs::File;
183+
//! use async_std::io::BufReader;
184+
//! use async_std::prelude::*;
185185
//!
186186
//! # fn main() -> std::io::Result<()> { async_std::task::block_on(async {
187187
//! #

src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@
154154
//!
155155
//! ```toml
156156
//! [dependencies.async-std]
157-
//! version = "0.99"
157+
//! version = "1.0.0"
158158
//! features = ["unstable"]
159159
//! ```
160160
//!
@@ -167,7 +167,7 @@
167167
//!
168168
//! ```toml
169169
//! [dependencies.async-std]
170-
//! version = "0.99"
170+
//! version = "1.0.0"
171171
//! features = ["attributes"]
172172
//! ```
173173
//!
@@ -176,7 +176,7 @@
176176
//!
177177
//! ```toml
178178
//! [dependencies.async-std]
179-
//! version = "0.99"
179+
//! version = "1.0.0"
180180
//! default-features = false
181181
//! features = ["std"]
182182
//! ```

src/stream/extend.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ pub trait Extend<A> {
6565
/// ```
6666
#[cfg(feature = "unstable")]
6767
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
68-
pub async fn extend<'a, C, A, T>(collection: &mut C, stream: T)
68+
pub async fn extend<'a, C, T, S>(collection: &mut C, stream: S)
6969
where
70-
C: Extend<A>,
71-
T: IntoStream<Item = A> + 'a,
70+
C: Extend<T>,
71+
S: IntoStream<Item = T> + 'a,
7272
{
7373
Extend::extend(collection, stream).await
7474
}

src/stream/from_fn.rs

Lines changed: 25 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,21 @@
1-
use std::marker::PhantomData;
21
use std::pin::Pin;
3-
use std::future::Future;
4-
5-
use pin_project_lite::pin_project;
62

73
use crate::stream::Stream;
84
use crate::task::{Context, Poll};
95

10-
pin_project! {
11-
/// A stream that yields elements by calling a closure.
12-
///
13-
/// This stream is created by the [`from_fn`] function. See its
14-
/// documentation for more.
15-
///
16-
/// [`from_fn`]: fn.from_fn.html
17-
#[derive(Debug)]
18-
pub struct FromFn<F, Fut, T> {
19-
f: F,
20-
#[pin]
21-
future: Option<Fut>,
22-
__t: PhantomData<T>,
23-
}
6+
/// A stream that yields elements by calling a closure.
7+
///
8+
/// This stream is created by the [`from_fn`] function. See its
9+
/// documentation for more.
10+
///
11+
/// [`from_fn`]: fn.from_fn.html
12+
#[derive(Clone, Debug)]
13+
pub struct FromFn<F> {
14+
f: F,
2415
}
2516

17+
impl<F> Unpin for FromFn<F> {}
18+
2619
/// Creates a new stream where to produce each new element a provided closure is called.
2720
///
2821
/// This allows creating a custom stream with any behaviour without using the more verbose
@@ -34,22 +27,15 @@ pin_project! {
3427
/// # async_std::task::block_on(async {
3528
/// #
3629
/// use async_std::prelude::*;
37-
/// use async_std::sync::Mutex;
38-
/// use std::sync::Arc;
3930
/// use async_std::stream;
4031
///
41-
/// let count = Arc::new(Mutex::new(0u8));
32+
/// let mut count = 0u8;
4233
/// let s = stream::from_fn(|| {
43-
/// let count = Arc::clone(&count);
44-
///
45-
/// async move {
46-
/// *count.lock().await += 1;
47-
///
48-
/// if *count.lock().await > 3 {
49-
/// None
50-
/// } else {
51-
/// Some(*count.lock().await)
52-
/// }
34+
/// count += 1;
35+
/// if count > 3 {
36+
/// None
37+
/// } else {
38+
/// Some(count)
5339
/// }
5440
/// });
5541
///
@@ -61,38 +47,21 @@ pin_project! {
6147
/// #
6248
/// # })
6349
/// ```
64-
pub fn from_fn<T, F, Fut>(f: F) -> FromFn<F, Fut, T>
50+
pub fn from_fn<T, F>(f: F) -> FromFn<F>
6551
where
66-
F: FnMut() -> Fut,
67-
Fut: Future<Output = Option<T>>,
52+
F: FnMut() -> Option<T>,
6853
{
69-
FromFn {
70-
f,
71-
future: None,
72-
__t: PhantomData,
73-
}
54+
FromFn { f }
7455
}
7556

76-
impl<F, Fut, T> Stream for FromFn<F, Fut, T>
57+
impl<T, F> Stream for FromFn<F>
7758
where
78-
F: FnMut() -> Fut,
79-
Fut: Future<Output = Option<T>>,
59+
F: FnMut() -> Option<T>,
8060
{
8161
type Item = T;
8262

83-
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
84-
let mut this = self.project();
85-
loop {
86-
if this.future.is_some() {
87-
let next =
88-
futures_core::ready!(this.future.as_mut().as_pin_mut().unwrap().poll(cx));
89-
this.future.set(None);
90-
91-
return Poll::Ready(next);
92-
} else {
93-
let fut = (this.f)();
94-
this.future.set(Some(fut));
95-
}
96-
}
63+
fn poll_next(mut self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Option<Self::Item>> {
64+
let item = (&mut self.f)();
65+
Poll::Ready(item)
9766
}
9867
}

src/stream/from_iter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::stream::Stream;
66
use crate::task::{Context, Poll};
77

88
pin_project! {
9-
/// A stream that created from iterator
9+
/// A stream that was created from iterator.
1010
///
1111
/// This stream is created by the [`from_iter`] function.
1212
/// See it documentation for more.

src/stream/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,9 +306,7 @@ pub use from_iter::{from_iter, FromIter};
306306
pub use once::{once, Once};
307307
pub use repeat::{repeat, Repeat};
308308
pub use repeat_with::{repeat_with, RepeatWith};
309-
pub use stream::{
310-
Chain, Filter, Fuse, Inspect, Scan, Skip, SkipWhile, StepBy, Stream, Take, TakeWhile, Zip,
311-
};
309+
pub use stream::*;
312310

313311
pub(crate) mod stream;
314312

src/stream/once.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ pin_project! {
3333
/// documentation for more.
3434
///
3535
/// [`once`]: fn.once.html
36-
#[derive(Debug)]
36+
#[derive(Clone, Debug)]
3737
pub struct Once<T> {
3838
value: Option<T>,
3939
}

src/stream/repeat.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ where
3333
/// documentation for more.
3434
///
3535
/// [`repeat`]: fn.repeat.html
36-
#[derive(Debug)]
36+
#[derive(Clone, Debug)]
3737
pub struct Repeat<T> {
3838
item: T,
3939
}

0 commit comments

Comments
 (0)