Skip to content

Conversation

quickdudley
Copy link

In response to #55

Two new methods in UI:

  1. async_context creates a token (iui::concurrent::Context) which can serve as evidence that UI::init() has run successfully; this token is Send
  2. spawn schedules an async function or future on the main thread. Since it's a method in UI it can only be run in the main thread. It returns control to the main loop when it blocks and queues itself again when it's ready again.

Two methods in concurrent::Context

  1. queue_main behaves like UI::queue_main in that it schedules a closure or function to run on the main thread. Unlike UI::queue_main it can be run in other threads but requires the closure to be Send.
  2. spawn behaves like UI::spawn but can be run from other threads; requires the future to be Send

Using UI::spawn and an async channel such as provided by tokio::sync::mpsc we can wait for things to happen on other threads without busy waiting or blocking other events and then update our widgets accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant