kpreid / yield-progress

Progress reporting and cooperative task yielding in Rust
Apache License 2.0
2 stars 0 forks source link

Efficient wrapper creation #32

Open kpreid opened 1 month ago

kpreid commented 1 month ago

An application might want to take an existing YieldProgress and wrap it so that progress information is routed to additional destinations. Currently, there is no way to do this without heap-allocating another Yielding, and failing to propagate the yield-point Location information. To avoid this, there should be a function which allows cloning the yielding configuration from an existing YieldProgress — or possibly cloning everything by default, perhaps written like YieldProgress::to_builder().

This could also be used internally by YieldProgress::split_evenly_concurrent(), which currently uses crate-private functions to get the same result.

kpreid commented 2 days ago

take an existing YieldProgress and wrap it so that progress information is routed to additional destinations.

A wrinkle with doing this is that if we naïvely allow replacing the existing progress function, this will reveal the current range endpoints. So, the new YieldProgress must have its range reset to 0..1, and we must create a wrapper on the existing progress function to preserve the range mapping it was already using.