kpreid / yield-progress

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

`no_std` / `!Send` support #2

Closed kpreid closed 10 months ago

kpreid commented 10 months ago

YieldProgress is, broadly, just an interface for reporting things up the (async) call stack. Therefore, no_std compatibility is a reasonable goal. Obstacles:

The complication is that if we decide to control the use of std::sync via an optional std frature, we would have YieldProgress: !Send, but (to preserve additivity of features) , we'd still have to impose a Sync bound on the provided yielder and progressor functions, which is inconvenient for users.

kpreid commented 10 months ago

Also, a good no_std version would be usable without heap allocations; however, this would require a lifetime (YieldProgress<'a>) which would interfere with use cases involving complex async callbacks. Possibly the answer is to offer creating YieldProgress<'static> (with internal Arcs) for those cases, but I suspect that for flexibility, in the end we're going to lose YieldProgress being a single type, and instead have it be parameterized over characteristics like the Syncness of the callbacks and the type of labels (with the ability to wrap one kind to become another to suit different crates).