-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
@hawkw and I were discussing a Uncancelable<F: FusedFuture> wrapper which runs a future, and spawns a task with the remaining work if the future is dropped before being completed. It is possible to write that, but it ran into several issues:
- It's basically equivalent to eagerly spawning a task.
- It requires the future to be
Unpin, so it can be moved out of theUncancelablefuture in order to spawn it as a task in theDropimpl. This implies that if the future is an async block, it would need to be eagerly boxed at construction time. So you aren't saving on allocations. - All the other typical limitations of spawning tasks apply, such that the future must be
Send + 'static.
The one advantage is that it would avoid spawning a task if the wrapper is run to completion, but honestly the added complexity doesn't seem worth it.
We should document this in a "negative results" section in the cancel-safe-futures docs.
hawkw
Metadata
Metadata
Assignees
Labels
No labels