futures-lite icon indicating copy to clipboard operation
futures-lite copied to clipboard

Add a trait for abstracing over executors

Open notgull opened this issue 1 year ago • 12 comments

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, as futures-task doesn't really fit well with async-executor outside of the basics.
  • Have our own Spawn trait that returns a Task trait that is a superset of Future.

@smol-rs/admins Thoughts?

notgull avatar Jan 19 '24 03:01 notgull