-
Notifications
You must be signed in to change notification settings - Fork 163
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
do not panic when failing to create a LocalExecutor
#500
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Besides some stylistic ideas and the API thing regarding what type of result we return, the rest is pretty straight forward and all good.
glommio/src/executor/mod.rs
Outdated
@@ -592,10 +592,11 @@ impl LocalExecutorBuilder { | |||
/// [`LocalExecutor::run`]:struct.LocalExecutor.html#method.run | |||
#[must_use = "This spawns an executor on a thread, so you may need to call \ | |||
`JoinHandle::join()` to keep the main thread alive"] | |||
pub fn spawn<G, F, T>(self, fut_gen: G) -> Result<JoinHandle<()>> | |||
pub fn spawn<G, F, T>(self, fut_gen: G) -> io::Result<JoinHandle<io::Result<T>>> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't these Results be glommio::Error variants to explain to the user what happened? Also shouldn't we just give the user the ability to return a result of their choosing from the main future?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do! The T
in there can be anything the user wants. They can return a Result
if they so wish. The two errors you see are respectively:
- The error thrown by
join()
if thestd::thread::Thread
failed to create or panicked - The error thrown by
LocalExecutor::new
if we fail to create it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It still seems like we need to return a glommio Error type (not an io::Error, from the io::Result) for functions that are public like this.
9b91981
to
f7c9237
Compare
I updated the PR to include a new type of |
f7c9237
to
2489d16
Compare
Agree with Bryan on not using io::Result, but other than that looks good. |
2489d16
to
546c2fe
Compare
Errors should propagate to the end users instead. Additionally, allow returning a struct from the boot future. It is possible to do so when using the pool builder but not when using the simple one, so this brings them to parity.
546c2fe
to
de3662f
Compare
The latest version uses GlommioError all the way through. Users can now inspect exactly why the executor failed to create 👍 |
Errors should propagate to the end users instead. Additionally,
allow returning a struct from the boot future. It is possible to do so
when using the pool builder but not when using the simple one, so this
brings them to parity.