Skip to content
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

Use std::thread::sleep instead of spin-waiting in the async_compute example #11856

Merged
merged 2 commits into from
Feb 14, 2024

Conversation

BD103
Copy link
Member

@BD103 BD103 commented Feb 13, 2024

Objective

  • The async_compute example uses an empty busy loop.
  • Since the loop is not doing anything and runs for a specific amount of time, it can be replaced with std::thread::sleep.

Solution

  • Replace busy loop in async_compute with std::thread::sleep.

@alice-i-cecile
Copy link
Member

alice-i-cecile commented Feb 13, 2024

Hmm. I think that we should just call sleep here :) Or have a my_expensive_function that just calls sleep.

@alice-i-cecile alice-i-cecile added C-Examples An addition or correction to our examples A-Tasks Tools for parallel and async work labels Feb 13, 2024
Copy link
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Can you update your PR title and description?

@james7132 james7132 changed the title Add spin_loop hint to async_compute example Use std::thread::sleep instead of spin-waiting in the async_compute example Feb 14, 2024
@alice-i-cecile alice-i-cecile added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Feb 14, 2024
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Feb 14, 2024
Merged via the queue into bevyengine:main with commit ebf81c6 Feb 14, 2024
24 checks passed
@BD103 BD103 deleted the spin-loop branch February 14, 2024 12:55
@BD103
Copy link
Member Author

BD103 commented Feb 14, 2024

Looks good. Can you update your PR title and description?

Done, sorry for the delay. The PR was merged too early, so the commit message won't reflect the changes. Can this be amended, or is it fine?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Tasks Tools for parallel and async work C-Examples An addition or correction to our examples S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants