mirror of
https://github.com/emilk/egui.git
synced 2026-06-27 07:03:14 -04:00
<!-- Please read the "Making a PR" section of [`CONTRIBUTING.md`](https://github.com/emilk/egui/blob/master/CONTRIBUTING.md) before opening a Pull Request! * Keep your PR:s small and focused. * The PR title is what ends up in the changelog, so make it descriptive! * If applicable, add a screenshot or gif. * If it is a non-trivial addition, consider adding a demo for it to `egui_demo_lib`, or a new example. * Do NOT open PR:s from your `master` branch, as that makes it hard for maintainers to test and add commits to your PR. * Remember to run `cargo fmt` and `cargo clippy`. * Open the PR as a draft until you have self-reviewed it and run `./scripts/check.sh`. * When you have addressed a PR comment, mark it as resolved. Please be patient! I will review your PR, but my time is limited! --> * Closes #2875 * Closes https://github.com/emilk/egui/pull/3340 * [x] I have followed the instructions in the PR template Adds `create_native`. Similiar to `run_native` but it returns an `EframeWinitApplication` which is a `winit::ApplicationHandler`. This can be run on your own event loop. A helper fn `pump_eframe_app` is provided to pump the event loop and get the control flow state back. I have been using this approach for a few months. --------- Co-authored-by: Will Brown <opensource@rebeagle.com>
11 lines
465 B
Markdown
11 lines
465 B
Markdown
Example running an eframe application on an external eventloop on top of a tokio executor on Linux.
|
|
|
|
By running the event loop, eframe, and tokio in the same thread, one can leverage local async tasks.
|
|
These tasks can share data with the UI without the need for locks or message passing.
|
|
|
|
In tokio CPU-bound async tasks can be run with `spawn_blocking` to avoid impacting the UI frame rate.
|
|
|
|
```sh
|
|
cargo run -p external_eventloop_async --features linux-example
|
|
```
|