async-rs / parallel-stream

Data parallelism library for async-std.
https://docs.rs/parallel-stream
Apache License 2.0
93 stars 16 forks source link

Limits #3

Closed yoshuawuyts closed 4 years ago

yoshuawuyts commented 4 years ago

Initializes the limit functionality outlined in #1. This only updates the traits to contain the functionality, and provide the methods. It does not yet enforce the limits, however.

The impl on how to enforce it is probably to create a stream wrapper that returns a tuple of (item, guard) that increments an internal counter if a limit has been set. Then when the guard is dropped, using an AtomicWaker it can wake the stream up to continue polling (while checking capacity).

Either way, this is a required first step to get us forward. Thanks!