-
Notifications
You must be signed in to change notification settings - Fork 2
Update the async runtime #42
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
Conversation
xermicus
left a comment
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.
LGTM! modulo some nits
Cargo.toml
Outdated
|
|
||
| # We set the `panic` behavior to `unwind` in both the `release` and `dev` profiles since our async | ||
| # runtime attempts to catch panics and it can only catch panics if we compile our code with unwind | ||
| # as the panic behavior. For more information, please see the `catch_unwind` documentation where it | ||
| # mentions that panics can only be caught if they unwind and not if they abort: | ||
| # https://doc.rust-lang.org/std/panic/fn.catch_unwind.html#notes | ||
|
|
||
| [profile.release] | ||
| panic = "unwind" | ||
|
|
||
| [profile.dev] | ||
| panic = "unwind" |
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.
This should be unnecessary as it's the default anyways?
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.
Ah good point, I was trying to be more explicit about it but I'm happy to just resort to keeping it implicit.
| // Creating a one-shot channel for this task that will be used to send and receive the | ||
| // response of the task. |
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.
| // Creating a one-shot channel for this task that will be used to send and receive the | |
| // response of the task. | |
| // Creating a one-shot channel for this task that will be used to send and receive the | |
| // response of the task. |
If anything the comment should say why you use a one-shot channel (don't just re-formulate the following code statement in human language).
Co-authored-by: xermicus <[email protected]>
Co-authored-by: xermicus <[email protected]>
Co-authored-by: xermicus <[email protected]>
Co-authored-by: xermicus <[email protected]>
Co-authored-by: xermicus <[email protected]>
Co-authored-by: xermicus <[email protected]>
Co-authored-by: xermicus <[email protected]>
Co-authored-by: xermicus <[email protected]>
Co-authored-by: xermicus <[email protected]>
Co-authored-by: xermicus <[email protected]>
|
@xermicus Thank you for the review! I realized that I over-commented a lot of parts of the code 😅 I accepted the suggestions you made and went back removing some of the older comments and only keeping comments where they're appropriate and meaningful. Let me know how it looks now |
xermicus
left a comment
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.
Thanks!
No worries. Looks much more concise now thank you! |
Summary
This PR updates the way in which we handled async tasks and
Futures in the codebase exposing theBlockingExecutorwhich allows for a simple way to execute async tasks in a blocking fashion and from blocking functions.Description
This PR implements the changes discussed in #40. More specifically, I changed how the codebase handles async tasks and
Futures to allow for us to more easily execute async tasks, which we might need soon as seen in #39. We still maintain all of the core characteristics of the previous solution in that the tokio runtime runs in a separate thread and all communication to and from the runtime happens over channels.This change is heavily inspired by our existing implementation. In fact, one could go as far as saying that it's just syntactic sugar over our previous implementation. It also adds new capabilities to the tokio runtime thread such as allowing it to catch panics gracefully so that a panic in one async task doesn't stop the entire code.
One of the nice things about this change is that we no longer need to define any new structs or trait implementations for tasks that we want to run on this executor, making use of it is as simple as: