feat: Add anyspawn crate with generic Spawner trait for spawn tasks for different async runtimes#193
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #193 +/- ##
=======================================
Coverage 100.0% 100.0%
=======================================
Files 135 138 +3
Lines 8199 8230 +31
=======================================
+ Hits 8199 8230 +31 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Have you thought about applying this guide to spawner? The idea is that For example: Tokio: let spawner = Spawner::new_tokio();Custom Runtime: let spawner = Spawner::new_custom(move |future| runtime_handle.spawn(future));The The downside of this approach is that we would enforce Send and Sync bounds, but this is aligned with https://microsoft.github.io/rust-guidelines/guidelines/libs/interop/index.html?highlight=Send#M-TYPES-SEND. |
I can see the value here. I guess the tradeoff would be some additional heap allocations and indirection internally, since the new_custom(...) closure will have to accept a boxed future. Once Oxidizer RT moves here we can add a direct enum variant for it to avoid that additional cost. In fact, we can probably remove this abstraction altogether at that point. |
I see the value of this type even when oxidizer rt is public. Sometimes, the library only needs to care about how to spawn tasks and using this type can simplify those scenarios. |
…es. Throw compile error without any features.
martintmk
left a comment
There was a problem hiding this comment.
few nits, otherwise looks good
No description provided.