Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: yoshuawuyts/futures-concurrency
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v7.2.1
Choose a base ref
...
head repository: yoshuawuyts/futures-concurrency
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref
Loading
Showing with 5,632 additions and 785 deletions.
  1. +27 −0 .github/workflows/ci.yaml
  2. +32 −14 Cargo.toml
  3. +62 −0 README.md
  4. +233 −2 benches/bench.rs
  5. +19 −0 benches/utils/countdown_futures.rs
  6. +20 −1 benches/utils/countdown_streams.rs
  7. +1 −1 examples/happy_eyeballs.rs
  8. +2 −0 src/collections/mod.rs
  9. +67 −0 src/collections/vec.rs
  10. +154 −0 src/concurrent_stream/enumerate.rs
  11. +206 −0 src/concurrent_stream/for_each.rs
  12. +174 −0 src/concurrent_stream/from_concurrent_stream.rs
  13. +100 −0 src/concurrent_stream/from_stream.rs
  14. +21 −0 src/concurrent_stream/into_concurrent_stream.rs
  15. +75 −0 src/concurrent_stream/limit.rs
  16. +182 −0 src/concurrent_stream/map.rs
  17. +238 −0 src/concurrent_stream/mod.rs
  18. +111 −0 src/concurrent_stream/take.rs
  19. +273 −0 src/concurrent_stream/try_for_each.rs
  20. +512 −0 src/future/future_group.rs
  21. +40 −1 src/future/futures_ext.rs
  22. +62 −39 src/future/join/array.rs
  23. +1 −0 src/future/join/mod.rs
  24. +77 −27 src/future/join/tuple.rs
  25. +55 −40 src/future/join/vec.rs
  26. +10 −1 src/future/mod.rs
  27. +1 −1 src/future/race/array.rs
  28. +1 −0 src/future/race/mod.rs
  29. +1 −1 src/future/race/tuple.rs
  30. +5 −1 src/future/race/vec.rs
  31. +4 −7 src/future/race_ok/array/error.rs
  32. +99 −15 src/future/race_ok/array/mod.rs
  33. +1 −0 src/future/race_ok/mod.rs
  34. +24 −0 src/future/race_ok/tuple/error.rs
  35. +29 −12 src/future/race_ok/tuple/mod.rs
  36. +9 −10 src/future/race_ok/vec/error.rs
  37. +12 −15 src/future/race_ok/vec/mod.rs
  38. +153 −50 src/future/try_join/array.rs
  39. +1 −0 src/future/try_join/mod.rs
  40. +296 −106 src/future/try_join/tuple.rs
  41. +168 −45 src/future/try_join/vec.rs
  42. +61 −0 src/future/wait_until.rs
  43. +154 −57 src/lib.rs
  44. +1 −0 src/stream/chain/mod.rs
  45. +4 −0 src/stream/chain/vec.rs
  46. +18 −16 src/stream/merge/array.rs
  47. +1 −0 src/stream/merge/mod.rs
  48. +13 −16 src/stream/merge/tuple.rs
  49. +15 −10 src/stream/merge/vec.rs
  50. +13 −4 src/stream/mod.rs
  51. +54 −1 src/stream/stream_ext.rs
  52. +486 −0 src/stream/stream_group.rs
  53. +63 −0 src/stream/wait_until.rs
  54. +22 −21 src/stream/zip/array.rs
  55. +1 −0 src/stream/zip/mod.rs
  56. +7 −6 src/stream/zip/tuple.rs
  57. +26 −21 src/stream/zip/vec.rs
  58. +2 −1 src/utils/array.rs
  59. +6 −4 src/utils/channel.rs
  60. +44 −0 src/utils/futures/array.rs
  61. +7 −0 src/utils/futures/mod.rs
  62. +47 −0 src/utils/futures/vec.rs
  63. +28 −6 src/utils/mod.rs
  64. +49 −0 src/utils/output/array.rs
  65. +7 −0 src/utils/output/mod.rs
  66. +52 −0 src/utils/output/vec.rs
  67. +5 −0 src/utils/pin.rs
  68. +39 −10 src/utils/poll_state/array.rs
  69. +4 −0 src/utils/poll_state/mod.rs
  70. +24 −16 src/utils/poll_state/poll_state.rs
  71. +64 −33 src/utils/poll_state/vec.rs
  72. +179 −0 src/utils/private.rs
  73. +28 −0 src/utils/stream.rs
  74. +12 −2 src/utils/wakers/array/mod.rs
  75. +88 −0 src/utils/wakers/array/no_std.rs
  76. +12 −9 src/utils/wakers/array/{readiness.rs → readiness_array.rs}
  77. +4 −4 src/utils/wakers/array/waker.rs
  78. +5 −5 src/utils/wakers/array/waker_array.rs
  79. +2 −1 src/utils/wakers/dummy.rs
  80. +4 −2 src/utils/wakers/mod.rs
  81. +12 −2 src/utils/wakers/vec/mod.rs
  82. +104 −0 src/utils/wakers/vec/no_std.rs
  83. +0 −70 src/utils/wakers/vec/readiness.rs
  84. +130 −0 src/utils/wakers/vec/readiness_vec.rs
  85. +4 −4 src/utils/wakers/vec/waker.rs
  86. +30 −5 src/utils/wakers/vec/waker_vec.rs
  87. +96 −0 tests/no_std.rs
  88. +47 −0 tests/regression-155.rs
  89. +0 −70 tests/test.rs
27 changes: 27 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -34,12 +34,31 @@ jobs:
command: check
args: --all --bins --examples

- name: check no-std
uses: actions-rs/cargo@v1
with:
command: check
args: --all --no-default-features

- name: check alloc
uses: actions-rs/cargo@v1
with:
command: check
args: --all --no-default-features --features alloc

- name: tests
uses: actions-rs/cargo@v1
with:
command: test
args: --all

msrv:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: taiki-e/install-action@cargo-hack
- run: cargo hack check --rust-version --workspace --all-targets --ignore-private

miri:
name: "Build and test (miri, nightly)"
runs-on: ubuntu-latest
@@ -72,3 +91,11 @@ jobs:

- name: Docs
run: cargo doc

semver-checks:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Check semver
uses: obi1kenobi/cargo-semver-checks-action@v2
46 changes: 32 additions & 14 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
[package]
name = "futures-concurrency"
version = "7.2.1"
version = "7.6.3"
license = "MIT OR Apache-2.0"
repository = "https://github.com/yoshuawuyts/futures-concurrency"
documentation = "https://docs.rs/futures-concurrency"
description = "Structured concurrency operations for async Rust"
readme = "README.md"
edition = "2018"
keywords = []
categories = []
authors = [
"Yoshua Wuyts <yoshuawuyts@gmail.com>"
]
edition = "2021"
keywords = ["async", "concurrency"]
categories = ["asynchronous", "concurrency"]
authors = ["Yoshua Wuyts <yoshuawuyts@gmail.com>"]
rust-version = "1.75.0"

[profile.bench]
debug = true

[lib]
bench = false
@@ -24,15 +26,31 @@ harness = false
name = "compare"
harness = false

[features]
default = ["std"]
std = ["alloc", "futures-lite/std"]
alloc = ["dep:fixedbitset", "dep:slab", "dep:smallvec", "futures-lite/alloc"]

[dependencies]
bitvec = { version = "1.0.1", default-features = false, features = ["alloc"] }
futures-core = "0.3"
pin-project = "1.0.8"
fixedbitset = { version = "0.5.7", default-features = false, optional = true }
futures-core = { version = "0.3", default-features = false }
futures-lite = { version = "2.5.0", default-features = false }
pin-project = "1.1"
slab = { version = "0.4.9", optional = true }
smallvec = { version = "1.13", optional = true }
futures-buffered = "0.2.9"

[dev-dependencies]
futures = "0.3.25"
futures-lite = "1.12.0"
criterion = { version = "0.3", features = ["async", "async_futures", "html_reports"] }
async-std = { version = "1.12.0", features = ["attributes"] }
async-io = "2.4"
async-std = { version = "1.13.0", features = ["attributes"] }
criterion = { version = "0.5", features = [
"async",
"async_futures",
"html_reports",
] }
futures = "0.3"
futures-time = "3.0.0"
itertools = "0.13"
lending-stream = "1.0.1"
rand = "0.8.5"
tokio = { version = "1.41", features = ["macros", "time", "rt-multi-thread"] }
62 changes: 62 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -41,6 +41,68 @@
</h3>
</div>

Performant, portable, structured concurrency operations for async Rust. It
works with any runtime, does not erase lifetimes, always handles
cancellation, and always returns output to the caller.

`futures-concurrency` provides concurrency operations for both groups of futures
and streams. Both for bounded and unbounded sets of futures and streams. In both
cases performance should be on par with, if not exceed conventional executor
implementations.

## Examples

**Await multiple futures of different types**
```rust
use futures_concurrency::prelude::*;
use std::future;

let a = future::ready(1u8);
let b = future::ready("hello");
let c = future::ready(3u16);
assert_eq!((a, b, c).join().await, (1, "hello", 3));
```

**Concurrently process items in a stream**

```rust
use futures_concurrency::prelude::*;

let v: Vec<_> = vec!["chashu", "nori"]
.into_co_stream()
.map(|msg| async move { format!("hello {msg}") })
.collect()
.await;

assert_eq!(v, &["hello chashu", "hello nori"]);
```

**Access stack data outside the futures' scope**

_Adapted from [`std::thread::scope`](https://doc.rust-lang.org/std/thread/fn.scope.html)._

```rust
use futures_concurrency::prelude::*;

let mut container = vec![1, 2, 3];
let mut num = 0;

let a = async {
println!("hello from the first future");
dbg!(&container);
};

let b = async {
println!("hello from the second future");
num += container[0] + container[2];
};

println!("hello from the main future");
let _ = (a, b).join().await;
container.push(4);
assert_eq!(num, container.len());
```

## Installation
```sh
$ cargo add futures-concurrency
Loading