Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Queueing async and sync functions on the main thread#114

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
quickdudley wants to merge2 commits intorust-native-ui:trunk
base:trunk
Choose a base branch
Loading
fromquickdudley:55-async-queue-main

Conversation

quickdudley
Copy link

In response to#55

Two new methods inUI:

  1. async_context creates a token (iui::concurrent::Context) which can serve as evidence thatUI::init() has run successfully; this token isSend
  2. spawn schedules an async function or future on the main thread. Since it's a method inUI 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 inconcurrent::Context

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

UsingUI::spawn and an async channel such as provided bytokio::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.

danieldulaney reacted with thumbs up emoji
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

1 participant
@quickdudley

[8]ページ先頭

©2009-2025 Movatter.jp