dyn-future

Crates.iodyn-future
lib.rsdyn-future
version3.0.4
sourcesrc
created_at2019-12-02 15:22:48.91772
updated_at2019-12-04 15:22:10.004744
descriptionConvenient and fast dynamic Futures for Rust.
homepage
repositoryhttps://github.com/xacrimon/dyn-future
max_upload_size
id185936
size11,661
Joel (xacrimon)

documentation

https://docs.rs/dyn-future

README

dyn-future

This is a small crate implementing convenient and fast dynamic Futures in Rust.

The DynFuture<T> type this library provides is intended as a replacement for the naive Box<dyn Future<Output = T>>.

Usability

This library is designed to be dead simple to use and require no setup. You can freely mix the naive boxed futures from dependencies and such without issue.

DynFuture<T> can be used the same way as Box<dyn Future<Output = T>> and most of the time you can just run find and replace on your existing code.

DynFuture<T> can be awaited like any other future, but it has a fixed size.

It should only be used as a replacement for Box<dyn Future<Output = T>>. If it is possible you should always prefer statically resolved futures using async fn.

Compilation overhead

dyn-future strives to be small and to minimize dependencies. If you have any questions or improvements to make, feel free to open an issue.

Why?

The provided DynFuture<T> type is faster than the naive implementation. Exactly how much depends on the global allocator, amount of CPU logical processors and the sizes of the futures sent. Though in general DynFuture<T> is always faster.

Currently we provide some extremely simple benchmarks. These could absolutely be improved. This is something I would like help with as I am not fantastic at writing benchmarks.

There are not representative of real world gains due to the lack of variation of future types. I have done some minor benchmarking of a proprietary codebase using dyn-future with over 8x gains in time spent handling dynamic futures.

Contributing

dyn-future gladly accepts contributions!

Open a PR and I will take a look.

Commit count: 0

cargo fmt