Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use the
oneshot
library for one-shot futures
`oneshot` handles one of our main use-cases with futures: a future that's completed by manually sending the result over one-shot channel. This replaces the `RunFuture` code and I hope to also use it for async callback interface methods. `oneshot` seems like a reasonable dependency to add. It's small, fairly popular, and replaces a lot of messy code. I doubt the performance matters, but FWIW I think it should perform much better than my naive mutex-based implementation for sending/receiving the value. We do lose one optimization: `RunFuture` stored the closure alongside the rest of the future internals which meant one less heap allocation. However, even that optimization comes at the cost of not being able to free the closure memory until the future was awaited and dropped by the consumer. Overall this seems like a win.
- Loading branch information