All notable changes to async-std will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
async-std
has officially been discontinued. We recommend that all users and
libraries migrate to the excellent smol
project.
BufReadExt
and SeekExt
from async_std::io
async_std::task::spawn_blocking
is now stabilized. We consider it a fundamental API for bridging between blocking code and async code, and we widely use it within async-std's own implementation.TryFrom
implementations to convert TcpListener
, TcpStream
, UdpSocket
, UnixDatagram
, UnixListener
, and UnixStream
to their synchronous equivalents, including putting them back into blocking mode.num_cpus
; it uses functionality in the standard library instead (via async-global-executor
).This release improves compile times by up to 55% on initial builds, and up to 75% on recompilation. Additionally we've added a few new APIs and made some tweaks.
TcpListener::into_incoming
to convert a TcpListener
into a stream of incoming TCP connectionsextension_trait
macro had been removed. This drastically improves compile times for async-std
, but changes the way our documentation is rendered. This is a cosmetic change only, and all existing code should continue to work as it did before.This release comes with an assortment of small features and fixes.
File
now implements Clone
so that File
s can be passed into closures for use in spawn_blocking
.
File
's contents are already wrapped in Arc
s, so the implementation of Clone
is straightforward.task::try_current()
which returns a handle to the current task if called within the context of a task created by async-std.async_std::io
now re-exports WriteExt
directly.write!
now takes already written bytes into account on File
.TcpStream
now properly makes use of vectored IO.net::*::Incoming
implementations now do less allocation.This patch stabilizes the async_std::channel
submodule, removes the
deprecated sync::channel
types, and introduces the tokio1
feature.
As part of our 1.8.0
release last month we introduced the new
async_std::channel
submodule and deprecated the unstable
async_std::sync::channel
types. You can read our full motivation for this
change in the last patch notes. But the short version is that the old
channels had some fundamental problems, and the sync
submodule is a bit of
a mess.
This release of async-std
promotes async_std::channel
to stable, and
fully removes the async_std::sync::channel
types. In practice many
libraries have already been upgraded to the new channels in the past month,
and this will enable much of the ecosystem to switch off "unstable" versions
of async-std
.
use async_std::channel;
let (sender, receiver) = channel::unbounded();
assert_eq!(sender.send("Hello").await, Ok(()));
assert_eq!(receiver.recv().await, Ok("Hello"));
The Tokio project recently released version 1.0 of their runtime, and the async-std team would like to congratulate the Tokio team on achieving this milestone.
This release of async-std
adds the tokio1
feature flag, enabling Tokio's
TLS constructors to be initialized within the async-std
runtime. This is in
addition to the tokio02
and tokio03
feature flags which we were already
exposing.
In terms of stability it's worth noting that we will continue to provide
support for the tokio02
, tokio03
, and tokio1
on the current major
release line of async-std
. These flags are part of our public API, and
removing compat support for older Tokio versions is considered a breaking
change.
sync::channel
(#933)FuturesExt
trait (#930)cargo-edit
in the installation section of the docs (#932)rand
to 0.8 (#923)RwLock
and Barrier
to use the async-lock
crate internally (#925)compare_and_swap
method with compare_exchange
(#927)This patch introduces async_std::channel
, a new submodule for our async channels implementation. channels
have been one of async-std's most requested features, and have existed as "unstable" for the past year. We've been cautious about stabilizing channels, and this caution turned out to be warranted: we realized our channels could hang indefinitely under certain circumstances, and people ended up expressing a need for unbounded channels.
So today we're introducing the new async_std::channel
submodule which exports the async-channel
crate, and we're marking the older unstable async_std::sync::channel
API as "deprecated". This release includes both APIs, but we intend to stabilize async_std::channel
and remove the older API in January. This should give dependent projects a month to upgrade, though we can extend that if it proves to be too short.
The rationale for adding a new top-level channel
submodule, rather than extending sync
is that the std::sync
and async_std::sync
submodule are a bit of a mess, and the libs team has been talking about splitting std::sync
up into separate modules. The stdlib has to guarantee it'll forever be backwards compatible, but async-std
does not (we fully expect a 2.0 once we have async closures & traits). So we're experimenting with this change before std
does, with the expectation that this change can serve as a data point when the libs team decides how to proceed in std.
async_std::channel
as "unstable" #915async_std::process
as "unstable" #916tokio03
flags in the docs #909StreamExt::cycle
#903pin-project
to v0.2.0
This patch adds a feature to enable compatibility with the new tokio
0.3.0
release, and updates internal dependencies.
tokio03
feature (#895)UdpSocket::peek
and UdpSocket::peek_from
(#853)Extracted the executor into async-global-executor (#867)
Updated various dependencies
UnixStream::into_raw_fd
doesn't close the file descriptor (#855)Mutex
implementation with async-mutex
. (#822)Send
guards to Stream::collect
. (#665)UdpSocket::peer_addr
(#816)flatten
and flat_map
(#701)tokio02
feature flag, to allow compatibility usage with tokio@0.2 (#804).stdio
lock methods, due to their unsoundness (#807).block_on
(#799) and (#809).default
feature requirement for the unstable
feature (#806).See 1.6.0-beta.1
and 1.6.0-beta.2
.
Clone
for UnixStream
(#772)wasm
, switched underlying Timer
implementation to futures-timer
. (#776)smol::block_on
to handle drop of File
, avoiding nested executor panic. (#768)task::spawn_local
. (#757)wasm
. (#757)JoinHandle::cancel
(#757)sync::Condvar
(#369)sync::Sender::try_send
and sync::Receiver::try_recv
(#585)no_std
support for task
, future
and stream
(#680)smol
. (#757)sync::Barrier
to use sync::Condvar
like std
does. (#581)AtomicUsize
for TaskId
. (#756)This patch includes various quality of life improvements to async-std.
Including improved performance, stability, and the addition of various
Clone
impls that replace the use of Arc
in many cases.
FromStream
for Result<T, E>
(#643)stream::pending
as "unstable" (#615)stream::timeout
to document the error flow (#675)Clone
for DirEntry
(#682)Clone
for TcpStream
(#689)stream::Interval
(#645)stream::FlatMap
(#651)1.0.0
(#681)async-task
to 1.2.1 (#676)task::block_on
now parks after a single poll, improving performance in many cases (#684)take_while
instead of scan
in impl
of Product
, Sum
and FromStream
(#667)TcpStream::connect
no longer uses a thread from the threadpool, improving performance (#687)UdpSocket::recv
(#648)UdpSocket::send
(#671)sync::JoinHandle
documentation (#659)std::error::Error::description
which failed CI (#661)format_code_in_doc_comments
option which failed CI (#685)task::sleep
example (#688)This patch adds Future::timeout
, providing a method counterpart to the
future::timeout
free function. And includes several bug fixes around missing
APIs. Notably we're not shipping our new executor yet, first announced on our
blog.
use async_std::prelude::*;
use async_std::future;
use std::time::Duration;
let fut = future::pending::<()>(); // This future will never resolve.
let res = fut.timeout(Duration::from_millis(100)).await;
assert!(res.is_err()); // The future timed out, returning an err.
Future::timeout
as "unstable" (#600)
stream
submodule documentation (#621)
Write::write_fmt
's future is now correctly marked as #[must_use]
(#628)
io::Bytes
export (#633)
io::Chain
export (#633)
io::Take
export (#633)
This patch introduces Stream::delay
, more methods on DoubleEndedStream
,
and improves compile times. Stream::delay
is a new API that's similar to
task::sleep
,
but can be passed as part of as stream, rather than as a separate block. This is
useful for examples, or when manually debugging race conditions.
let start = Instant::now();
let mut s = stream::from_iter(vec![0u8, 1]).delay(Duration::from_millis(200));
// The first time will take more than 200ms due to delay.
s.next().await;
assert!(start.elapsed().as_millis() >= 200);
// There will be no delay after the first time.
s.next().await;
assert!(start.elapsed().as_millis() <= 210);
Stream::delay
as "unstable" (#309)
DoubleEndedStream::next_back
as "unstable" (#562)
DoubleEndedStream::nth_back
as "unstable" (#562)
DoubleEndedStream::rfind
as "unstable" (#562)
DoubleEndedStream::rfold
as "unstable" (#562)
DoubleEndedStream::try_rfold
as "unstable" (#562)
stream::Once
now implements DoubleEndedStream
(#562)
stream::FromIter
now implements DoubleEndedStream
(#562)
async-macros
, speeding up compilation (#610)
UdpSocket::recv
example (#603)
task::block_on
(#608)
task::Builder
(#612)
futures-preview
(#595)
<TcpStream as Write>::poll_close
now closes the write half of the stream (#618)
This patch includes some minor quality-of-life improvements, introduces a
new Stream::unzip
API, and adds verbose errors to our networking types.
This means if you can't connect to a socket, you'll never have to wonder again which address it was you couldn't connect to, instead of having to go through the motions to debug what the address was.
Unzip a stream of tuples into two collections:
use async_std::prelude::*;
use async_std::stream;
let s = stream::from_iter(vec![(1,2), (3,4)]);
let (left, right): (Vec<_>, Vec<_>) = s.unzip().await;
assert_eq!(left, [1, 3]);
assert_eq!(right, [2, 4]);
Stream::unzip
as "unstable".Future::join
and Future::try_join
can now join futures with different
output types.Debug
output of BufWriter
.Stream::throttle
that made it consume too much CPU.This patch introduces a faster scheduler algorithm, Stream::throttle
, and
stabilizes task::yield_now
. Additionally we're introducing several more stream
APIs, bringing us to almost complete parity with the standard library.
Furthermore our path
submodule now returns more context in errors. So if
opening a file fails, async-std will tell you which file was failed to open,
making it easier to write and debug programs.
let start = Instant::now();
let mut s = stream::interval(Duration::from_millis(5))
.throttle(Duration::from_millis(10))
.take(2);
s.next().await;
assert!(start.elapsed().as_millis() >= 5);
s.next().await;
assert!(start.elapsed().as_millis() >= 15);
s.next().await;
assert!(start.elapsed().as_millis() >= 25);
Stream::throttle
as "unstable".Stream::count
as "unstable".Stream::max
as "unstable".Stream::successors
as "unstable".Stream::by_ref
as "unstable".Stream::partition
as "unstable".path
submodule.os::windows::symlink_dir
as "unstable".os::windows::symlink_file
as "unstable".task::yield_now
.read
calls on File
.Stream::max_by_key
was returning the wrong result.Stream::min_by_key
was returning the wrong result.Unpin
bound from stream::Once
.pin_mut!
.Stream::any
and Stream::all
's internals.surf
example is now enabled again.futures-timer
to 2.0.0, improving compilation speed.async-macros
to 2.0.0.Stream::merge
now uses randomized ordering to reduce overall latency.channel
types to link back to the channel
function.We were seeing a regression in our fs performance, caused by too many long-running tasks. This patch fixes that regression by being more proactive about closing down idle threads.
task::spawn_blocking
.This release marks the 1.0.0
release of async-std; a major milestone for our
development. This release itself mostly includes quality of life improvements
for all of modules, including more consistent API bounds for a lot of our
submodules.
The biggest change is that we're now using the full semver range,
major.minor.patch
, and any breaking changes to our "stable" APIs will require
an update of the major
number.
We're excited we've hit this milestone together with you all. Thank you!
Future::join
as "unstable", replacing future::join!
.Future::try_join
as "unstable", replacing future::try_join!
.stable
and beta
channel testing on CI.FromIterator
and Extend
for PathBuf
.FromStream
for PathBuf
.io::copy
on "unstable".Sync
bound to RwLock
, resolving a memory safety issue.Stream::take_while
where it could continue after it should've
ended.attributes
Cargo feature wasn't working as intended.Stream::merge
, documenting ordering guarantees.future
submodule.path
submodule.stream
submodule.future::join!
in favor of Future::join
.future::try_join!
in favor of Future::try_join
.This patch upgrades us to futures
0.3, support for async/await
on Rust
Stable, performance improvements, and brand new module-level documentation.
Future::flatten
as "unstable".Future::race
as "unstable" (replaces future::select!
).Future::try_race
as "unstable" (replaces future::try_select!
).Stderr::lock
as "unstable".Stdin::lock
as "unstable".Stdout::lock
as "unstable".Stream::copied
as "unstable".Stream::eq
as "unstable".Stream::max_by_key
as "unstable".Stream::min
as "unstable".Stream::ne
as "unstable".Stream::position
as "unstable".StreamExt
and FutureExt
as enumerable in the prelude
.TcpListener
and TcpStream
integration tests.stream::from_iter
.sync::WakerSet
for internal use.IP v4
and IP v6
connections.default
Cargo feature.attributes
Cargo feature.std
Cargo feature.Stream::merge
where sometimes it ended too soon.task
module.futures-preview
with futures
.lazy_static
with once_cell
.VecDequeue
in the examples with stream::from_iter
.sync::RwLock
using the internal sync::WakerSet
type.path
submodule documentation to match std.future::select!
(replaced by Future::race
).future::try_select!
(replaced by Future::try_race
).This patch introduces async_std::sync::channel
, a novel asynchronous port of
the ultra-fast Crossbeam channels. This has been one of the most anticipated
features for async-std, and we're excited to be providing a first version of
this!
In addition to channels, this patch has the regular list of new methods, types, and doc fixes.
Send and receive items from a channel
// Create a bounded channel with a max-size of 1
let (s, r) = channel(1);
// This call returns immediately because there is enough space in the channel.
s.send(1).await;
task::spawn(async move {
// This call blocks the current task because the channel is full.
// It will be able to complete only after the first message is received.
s.send(2).await;
});
// Receive items from the channel
task::sleep(Duration::from_secs(1)).await;
assert_eq!(r.recv().await, Some(1));
assert_eq!(r.recv().await, Some(2));
Future::delay
as "unstable"Stream::flat_map
as "unstable"Stream::flatten
as "unstable"Stream::product
as "unstable"Stream::sum
as "unstable"Stream::min_by_key
Stream::max_by
Stream::timeout
as "unstable"sync::channel
as "unstable".Extend
+ FromStream
for PathBuf
.block_on
so it works even when nested.cfg_if
with our own macros, simplifying the codebase.Cargo.toml
to point to async.rs.stream
and sync
.File
operationsNothing was removed in this release.
This patch stabilizes several core concurrency macros, introduces async versions
of Path
and PathBuf
, and adds almost 100 other commits.
Asynchronously read directories from the filesystem
use async_std::fs;
use async_std::path::Path;
use async_std::prelude::*;
let path = Path::new("/laputa");
let mut dir = fs::read_dir(&path).await.unwrap();
while let Some(entry) = dir.next().await {
if let Ok(entry) = entry {
println!("{:?}", entry.path());
}
}
Cooperatively reschedule the current task on the executor
use async_std::prelude::*;
use async_std::task;
task::spawn(async {
let x = fibonacci(1000); // Do expensive work
task::yield_now().await; // Allow other tasks to run
x + fibonacci(100) // Do more work
})
Create an interval stream
use async_std::prelude::*;
use async_std::stream;
use std::time::Duration;
let mut interval = stream::interval(Duration::from_secs(4));
while let Some(_) = interval.next().await {
println!("prints every four seconds");
}
FutureExt
to the prelude
, allowing us to extend Future
Stream::cmp
Stream::ge
Stream::last
Stream::le
Stream::lt
Stream::merge
as "unstable", replacing stream::join!
Stream::partial_cmp
Stream::take_while
Stream::try_fold
future::IntoFuture
as "unstable"io::BufRead::split
io::Write::write_fmt
print!
, println!
, eprint!
, eprintln!
macros as "unstable"process
as "unstable", re-exporting std types only for nowstd::net
re-exports to the net
submodulestd::path::PathBuf
with all associated methodsstd::path::Path
with all associated methodsstream::ExactSizeStream
as "unstable"stream::FusedStream
as "unstable"stream::Product
stream::Sum
stream::from_fn
stream::interval
as "unstable"stream::repeat_with
task::spawn_blocking
as "unstable", replacing task::blocking
task::yield_now
write!
and writeln!
macros as "unstable"future::join!
and future::try_join!
future::timeout
path
task::ready!
BufWriter::into_inner
so it calls flush
before yieldingio::BufWriter
internalsnet::ToSocketAddrs
internalsio::Cursor
io
documentation to match std's io
docstask
documentation to match std's thread
docsstream::join!
in favor of Stream::merge
task::blocking
in favor of task::spawn_blocking
This patch upgrades our futures-rs
version, allowing us to build on the 1.39
beta. Additionally we've introduced map
and for_each
to Stream
. And we've
added about a dozen new FromStream
implementations for std
types, bringing
us up to par with std's FromIterator
implementations.
And finally we've added a new "unstable" task::blocking
function which can be
used to convert blocking code into async code using a threadpool. We've been
using this internally for a while now to async-std to power our fs
and
net::SocketAddr
implementations. With this patch userland code now finally has
access to this too.
Create a stream of tuples, and collect into a hashmap
let a = stream::once(1u8);
let b = stream::once(0u8);
let s = a.zip(b);
let map: HashMap<u8, u8> = s.collect().await;
assert_eq!(map.get(&1), Some(&0u8));
Spawn a blocking task on a dedicated threadpool
task::blocking(async {
println!("long-running task here");
}).await;
stream::Stream::map
stream::Stream::for_each
stream::Stream::try_for_each
task::blocking
as "unstable"FromStream
for all std::{option, collections, result, string, sync}
types.path
submodule as "unstable".futures-preview
to 0.3.0-alpha.19
, allowing us to build on rustc 1.39.0-beta
.Stream::size_hint
to optimize internal allocations.sync::Barrier
docs to match std.stream::FromStream
docs to match std's FromIterator
.io::Read::take
method.io::Read::by_ref
method.io::Read::chain
method.0.3.0-alpha.18
, to avoid rustc upgrade problems.broadcast
module with std::sync::Mutex
, reducing dependencies.future::join
macro as "unstable"future::select
macro as "unstable"future::try_join
macro as "unstable"future::try_select
macro as "unstable"io::BufWriter
structstream::Extend
traitstream::Stream::chain
methodstream::Stream::filter
methodstream::Stream::inspect
methodstream::Stream::skip_while
methodstream::Stream::skip
methodstream::Stream::step_by
methodsync::Arc
struct from stdlibsync::Barrier
struct as "unstable"sync::Weak
struct from stdlibtask::ready
macro as "unstable"pin
submodule as "unstable" in the docs_loop
io
traits are now re-exports of futures-rs types, allowing them to be
implementedstream
traits are now re-exports of futures-rs types, allowing them to be
implementedprelude::*
now needs to be in scope for functions io
and stream
traits
to workstream::Stream::collect
as "unstable"stream::Stream::enumerate
stream::Stream::fuse
stream::Stream::fold
stream::Stream::scan
stream::Stream::zip
stream::join
macro as "unstable"stream::DoubleEndedStream
as "unstable"stream::FromStream
trait as "unstable"stream::IntoStream
trait as "unstable"io::Cursor
as "unstable"io::BufRead::consume
methodio::repeat
io::Slice
and io::SliceMut
pin
submodule as "unstable"collect
a stream of Result<T, E>
s into a
Result<impl FromStream<T>, E>
Send
bound from task::block_on
Unpin
bound from impl<T: futures::stream::Stream> Stream for T
io::timeout
io::BufRead::fill_buf
, an async fn
counterpart to poll_fill_buf
fs::create_dir_all
future::timeout
, a free function to time out futures after a thresholdio::prelude
net::ToSocketAddrs
, a non-blocking version of std's ToSocketAddrs
stream::Stream::all
stream::Stream::filter_map
stream::Stream::find_map
stream::Stream::find
stream::Stream::min_by
stream::Stream::nth
cargo fmt
on all examplesTcpStream::connect_to
futures-rs
crate, improving compilation timesio::Read
, io::Write
, io::BufRead
, and stream::Stream
into
multiple filesfs::File
now flushes more often to prevent flushes during seek
File
into raw handleВы можете оставить комментарий после Вход в систему
Неприемлемый контент может быть отображен здесь и не будет показан на странице. Вы можете проверить и изменить его с помощью соответствующей функции редактирования.
Если вы подтверждаете, что содержание не содержит непристойной лексики/перенаправления на рекламу/насилия/вульгарной порнографии/нарушений/пиратства/ложного/незначительного или незаконного контента, связанного с национальными законами и предписаниями, вы можете нажать «Отправить» для подачи апелляции, и мы обработаем ее как можно скорее.
Опубликовать ( 0 )