futures-lite
futures-lite copied to clipboard
Add a trait for abstracing over executors
In smol
, Executor
and LocalExecutor
don't implement any common traits. So, it's impossible to create a common abstraction over both traits. This is a blocker for https://github.com/notgull/smol-hyper/pull/2#issuecomment-1896504478 and https://github.com/smol-rs/smol/issues/292.
However I think that we should have an abstraction for executors in general. We put an emphasis on a diversity of executors like smolscale
but we have no way of abstracting over them. Therefore I think we should have a trait for spawning futures, specifically in this crate.
A couple of potential strategies here:
- We could just bring in
futures-task
, which would fit the general ethos of this crate. However I think that we should avoid this, asfutures-task
doesn't really fit well withasync-executor
outside of the basics. - Have our own
Spawn
trait that returns aTask
trait that is a superset ofFuture
.
@smol-rs/admins Thoughts?