I've modified FuturesUnordered to create the MappedFutures library. I would appreciate any feedback on the usefulness of this library and its soundness.
Whereas FuturesUnordered can be added to with push()
and futures cannot be removed except by polling them with next()
. MappedFutures can be added to with insert()
, they can be retrieved for mutation with get_mut()
, and they can be cancelled with remove()
or the unsafe remove_pinned()
, of which only the latter returns the future.
Making the changes was difficult, but I've written tests that now run without error, but of course that does not guarantee that the changes are sound in all circumstances. If anyone out there has time and interest, any reports of unsoundness in the library would be greatly appreciated.
With the exception of the new methods, the library is changed mainly to add the K: Hash + Eq +Clone
generic to all the library's types, and to add/remove tasks when appropriate from the new HashMap field of MappedFutures.
Edit: I've published the crate here https://crates.io/crates/mapped_futures