-
Notifications
You must be signed in to change notification settings - Fork 179
feat: Spawn layout evaluation #2348
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 31 commits
308d804
6978c28
bea1dbc
29e1da2
c78ed3a
ef2bf80
322c72a
b4a5b08
a90fd9d
96e119d
aead48a
be57a8f
c744f90
bd4c6ff
6dbab42
defc115
45b39a1
fadcc6d
8a127ec
bf14120
539bacb
6032cbe
625789d
3e91ef8
8c568e9
d6381e4
cab3012
df579e9
78f4eb0
41aa3d1
a643a5d
b1133f1
169bea9
f210bbc
5e171f2
f3ecbb7
32067e1
ea6103c
a775f89
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| #[cfg(feature = "tokio")] | ||
| mod tokio; | ||
|
|
||
| mod threads; | ||
|
|
||
| use std::future::Future; | ||
|
|
||
| use futures::future::BoxFuture; | ||
| pub use threads::*; | ||
| #[cfg(feature = "tokio")] | ||
| pub use tokio::*; | ||
| use vortex_error::VortexResult; | ||
|
|
||
| pub trait Executor { | ||
| /// Spawns a future to run on a different runtime. The shouldn't be polled to make progress. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix up doc
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. LMK what you think of the new one |
||
| fn spawn<F>(&self, f: F) -> VortexResult<BoxFuture<'static, VortexResult<F::Output>>> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this need to return a result? Can it just be
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don' think we want to return |
||
| where | ||
| F: Future + Send + 'static, | ||
| <F as Future>::Output: Send + 'static; | ||
| } | ||
|
|
||
| /// Generic wrapper around different async runtimes. Used to spawn async tasks to run in the background, concurrently with other tasks. | ||
| #[derive(Clone)] | ||
| pub enum TaskExecutor { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder what the performance hit is to just have a
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IDK if we can have
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You would have to take / return BoxFuture. You already return one
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think its that much code (probably less than what happens in |
||
| Threads(ThreadsExecutor), | ||
| #[cfg(feature = "tokio")] | ||
| Tokio(TokioExecutor), | ||
| } | ||
|
|
||
| pub enum TaskExecutorMode { | ||
|
AdamGS marked this conversation as resolved.
Outdated
|
||
| Threads, | ||
| #[cfg(feature = "tokio")] | ||
| Tokio, | ||
| } | ||
|
|
||
| #[async_trait::async_trait] | ||
| impl Executor for TaskExecutor { | ||
| fn spawn<F>(&self, f: F) -> VortexResult<BoxFuture<'static, VortexResult<F::Output>>> | ||
| where | ||
| F: Future + Send + 'static, | ||
| <F as Future>::Output: Send + 'static, | ||
| { | ||
| match self { | ||
| TaskExecutor::Threads(threads_executor) => threads_executor.spawn(f), | ||
| #[cfg(feature = "tokio")] | ||
| TaskExecutor::Tokio(tokio_executor) => tokio_executor.spawn(f), | ||
| } | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.