- Add a
closemethod onsink::Wait - Undeprecate
stream::iterasstream::iter_result - Improve performance of wait-related methods
- Tweak buffered sinks with a 0 capacity to forward directly to the underlying sink.
- Add
FromIteratorimplementation forFuturesOrderedandFuturesUnordered.
- A
preludemodule has been added to glob import from and pick up a whole bunch of useful types sync::mpsc::Sender::poll_readyhas been added as an APIsync::mpsc::Sender::try_sendhas been added as an API
- Improve performance of
BiLockmethods - Implement
CloneforFutureResult - Forward
Streamtrait throughSinkMapErr - Add
stream::futures_orderednext tofutures_unordered - Reimplement
Stream::bufferedon top ofstream::futures_ordered(much more efficient at scale). - Add a
with_notifyfunction for abstractions which previously requiredUnparkEvent. - Add
get_ref/get_mut/into_innerfunctions for stream take/skip methods - Add a
Cloneimplementation forSharedItemandSharedError - Add a
mpsc::spawnfunction to spawn aStreaminto anExecutor - Add a
reunitefunction forBiLockand the split stream/sink types to rejoin two halves and reclaim the original item. - Add
stream::poll_fnto behave similarly tofuture::poll_fn - Add
Sink::with_flat_maplikeIterator::flat_map - Bump the minimum Rust version to 1.13.0
- Expose
AtomicTaskin the public API for managing synchronization around task notifications. - Unify the
Canceledtype of thesyncandunsyncmodules. - Deprecate the
boxedmethods. These methods have caused more confusion than they've solved historically, so it's recommended to use a local extension trait or a local helper instead of the trait-based methods. - Deprecate the
Stream::mergemethod as it's less ergonomic thanselect. - Add
oneshot::Sender::is_canceledto test if a oneshot is canceled off a task. - Deprecates
UnboundedSender::sendin favor of a method namedunbounded_sendto avoid a conflict withSink::send. - Deprecate the
stream::iterfunction in favor of anstream::iter_okadaptor to avoid the need to deal withResultmanually. - Add an
inspectfunction to theFutureandStreamtraits along the lines ofIterator::inspect
This is a relatively large release of the futures crate, although much of it
is from reworking internals rather than new APIs. The banner feature of this
release is that the futures::{task, executor} modules are now available in
no_std contexts! A large refactoring of the task system was performed in
PR #436 to accommodate custom memory allocation schemes and otherwise remove
all dependencies on std for the task module. More details about this change
can be found on the PR itself.
Other API additions in this release are:
- A
FuturesUnordered::pushmethod was added and theFuturesUnorderedtype itself was completely rewritten to efficiently track a large number of futures. - A
Task::will_notify_currentmethod was added with a slightly different implementation thanTask::is_currentbut with stronger guarantees and documentation wording about its purpose. - Many combinators now have
get_ref,get_mut, andinto_innermethods for accessing internal futures and state. - A
Stream::concat2method was added which should be considered the "fixed" version ofconcat, this one doesn't panic on empty streams. - An
Executortrait has been added to represent abstracting over the concept of spawning a new task. Crates which only need the ability to spawn a future can now be generic overExecutorrather than requiring atokio_core::reactor::Handle.
As with all 0.1.x releases this PR is intended to be 100% backwards compatible. All code that previously compiled should continue to do so with these changes. As with other changes, though, there are also some updates to be aware of:
- The
task::parkfunction has been renamed totask::current. - The
Task::unparkfunction has been renamed toTask::notify, and in general terminology around "unpark" has shifted to terminology around "notify" - The
Unparktrait has been deprecated in favor of theNotifytrait mentioned above. - The
UnparkEventstructure has been deprecated. It currently should perform the same as it used to, but it's planned that in a future 0.1.x release the performance will regress for crates that have not transitioned away. The primary primitive to replace this is the addition of apushfunction on theFuturesUnorderedtype. If this does not help implement your use case though, please let us know! - The
Task::is_currentmethod is now deprecated, and you likely want to useTask::will_notify_currentinstead, but let us know if this doesn't suffice!
- Add forwarding sink/stream impls for
stream::FromErrandsink::SinkFromErr - Add
PartialEqandEqtompsc::SendError - Reimplement
Sharedwithspawninstead ofUnparkEvent
- Add
Stream::from_errandSink::from_err - Allow
SendErrorto beClonewhen possible
The major highlight of this release is the addition of a new "default" method on
the Sink trait, Sink::close. This method is used to indicate to a sink that
no new values will ever need to get pushed into it. This can be used to
implement graceful shutdown of protocols and otherwise simply indicates to a
sink that it can start freeing up resources.
Currently this method is not a default method to preserve backwards
compatibility, but it's intended to become a default method in the 0.2 series of
the futures crate. It's highly recommended to audit implementations of Sink
to implement the close method as is fit.
Other changes in this release are:
- A new select combinator,
Future::select2was added for a heterogeneous select. - A
Shared::peekmethod was added to check to see if it's done. Sink::map_errwas implemented- The
logdependency was removed - Implementations of the
Debugtrait are now generally available. - The
stream::IterStreamtype was renamed tostream::Iter(with a reexport for the old name). - Add a
Sink::waitmethod which returns an adapter to use an arbitrarySinksynchronously. - A
Stream::concatmethod was added to concatenate a sequence of lists. - The
oneshot::Sender::completemethod was renamed tosendand now returns aResultindicating successful transmission of a message or not. Note that thecompletemethod still exists, it's just deprecated.
- Add a new
unsyncmodule which mirrorssyncto the extent that it can but is intended to not perform cross-thread synchronization (only usable within one thread). - Tweak
Sharedto work when handles may not get poll'd again.
- Fix
Send/Syncof a few types - Add
future::tail_fnfor more easily writing loops - Export SharedItem/SharedError
- Remove an unused type parameter in
from_err
- Fix some race conditions in the
Sharedimplementation - Add
Stream::take_while - Fix an unwrap in
stream::futures_unordered - Generalize
Stream::for_each - Add
Stream::chain - Add
stream::repeat - Relax
&mut selfto&selfinUnboundedSender::send
- Add a
Future::sharedmethod for creating a future that can be shared amongst threads by cloning the future itself. All derivative futures will resolve to the same value once the original future has been resolved. - Add a
FutureFromtrait for future-based conversion - Fix a wakeup bug in
Receiver::close - Add
future::poll_fnfor quickly adapting aPoll-based function to a future. - Add an
Eitherenum with two branches to easily create one future type based on two different futures created on two branches of control flow. - Remove the
'staticbound onUnpark - Optimize
send_allandforwardto send as many items as possible before callingpoll_complete. - Unify the return types of the
ok,err, andresultfuture to assist returning different varieties in different branches of a function. - Add
CpuFuture::forgetto allow the computation to continue running after a drop. - Add a
stream::futures_unorderedcombinator to turn a list of futures into a stream representing their order of completion.
- Fix
Clonebound on the type parameter onUnboundedSender
- Fix
#![no_std]support
This is quite a large release relative to the previous point releases! As with all 0.1 releases, this release should be fully compatible with the 0.1.3 release. If any incompatibilities are discovered please file an issue!
The largest changes in 0.1.4 are the addition of a Sink trait coupled with a
reorganization of this crate. Note that all old locations for types/traits
still exist, they're just deprecated and tagged with #[doc(hidden)].
The new Sink trait is used to represent types which can periodically over
time accept items, but may take some time to fully process the item before
another can be accepted. Essentially, a sink is the opposite of a stream. This
trait will then be used in the tokio-core crate to implement simple framing by
modeling I/O streams as both a stream and a sink of frames.
The organization of this crate is to now have three primary submodules,
future, stream, and sink. The traits as well as all combinator types are
defined in these submodules. The traits and types like Async and Poll are
then reexported at the top of the crate for convenient usage. It should be a
relatively rare occasion that the modules themselves are reached into.
Finally, the 0.1.4 release comes with a new module, sync, in the futures
crate. This is intended to be the home of a suite of futures-aware
synchronization primitives. Currently this is inhabited with a oneshot module
(the old oneshot function), a mpsc module for a new multi-producer
single-consumer channel, and a BiLock type which represents sharing ownership
of one value between two consumers. This module may expand over time with more
types like a mutex, rwlock, spsc channel, etc.
Notable deprecations in the 0.1.4 release that will be deleted in an eventual 0.2 release:
- The
TaskRctype is now deprecated in favor ofBiLockor otherwiseArcsharing. - All future combinators should be accessed through the
futuremodule, not the top-level of the crate. - The
OneshotandCompletetypes are now replaced with thesync::oneshotmodule. - Some old names like
collectare deprecated in favor of more appropriately named versions likejoin_all - The
finishedconstructor is nowok. - The
failedconstructor is nowerr. - The
doneconstructor is nowresult.
As always, please report bugs to https://github.com/alexcrichton/futures-rs and we always love feedback! If you've got situations we don't cover, combinators you'd like to see, or slow code, please let us know!
Full changelog:
- Improve scalability of
buffer_unorderedcombinator - Fix a memory ordering bug in oneshot
- Add a new trait,
Sink - Reorganize the crate into three primary modules
- Add a new
syncmodule for synchronization primitives - Add a
BiLocksync primitive for two-way sharing - Deprecate
TaskRc - Rename
collecttojoin_all - Use a small vec in
Eventsfor improved clone performance - Add
Stream::selectfor selecting items from two streams likemergebut requiring the same types. - Add
stream::unfoldconstructor - Add a
sync::mpscmodule with a futures-aware multi-producer single-consumer queue. Both bounded (with backpressure) and unbounded (no backpressure) variants are provided. - Renamed
failed,finished, anddonecombinators toerr,ok, andresult. - Add
Stream::forwardto send all items to a sink, likeSink::send_all - Add
Stream::splitfor streams which are both sinks and streams to have separate ownership of the stream/sink halves - Improve
join_allwith concurrency
- Rewrite
oneshotfor efficiency and removing allocations on send/recv - Errors are passed through in
Stream::takeandStream::skip - Add a
select_okcombinator to pick the first of a list that succeeds - Remove the unnecessary
SelectAllNexttypedef - Add
Stream::chunksfor receiving chunks of data - Rewrite
stream::channelfor efficiency, correctness, and removing allocations - Remove
Send + 'staticbounds on thestream::Emptytype
- Fixed a bug in drop of
FutureSender - Expose the channel
SendErrortype - Add
Future::into_streamto convert to a single-element stream - Add
Future::flatten_to_streamto convert a future of a stream to a stream - impl Debug for SendError
- Add stream::once for a one element stream
- Accept IntoIterator in stream::iter
- Add
Stream::catch_unwind
Initial release!