-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for asynchronous code (#25)
This allows you to define an asynchronous `main` function instead of the poll based `update` function, which allows you to more easily keep state between individual ticks of the runtime. Unfortunately the most efficient implementation isn't possible yet on stable Rust, as we are blocked by the following two features: - [`type_alias_impl_trait`](rust-lang/rust#63063) - [`const_async_blocks`](rust-lang/rust#85368) For now we have to use a workaround that is less efficient by calling the `main` function at runtime and allocating it onto a new WebAssembly page. Here is a full example of how an auto splitter could look like using the `async_main` macro: Usage on stable Rust: ```rust async_main!(stable); ``` Usage on nightly Rust: ```rust async_main!(nightly); ``` The asynchronous main function itself: ```rust async fn main() { // TODO: Set up some general state and settings. loop { let process = Process::wait_attach("explorer.exe").await; process.until_closes(async { // TODO: Load some initial information from the process. loop { // TODO: Do something on every tick. next_tick().await; } }).await; } } ```
- Loading branch information
Showing
4 changed files
with
545 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.