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

Only lock once to wake a task #3644

Merged
merged 1 commit into from
Dec 16, 2024
Merged

Only lock once to wake a task #3644

merged 1 commit into from
Dec 16, 2024

Conversation

bugadani
Copy link
Contributor

@bugadani bugadani commented Dec 13, 2024

Waker::wake previously used two critical sections on targets without atomic CAS.

  • One to update the task state
  • One to call RunQueue::enqueue

This PR refactors State::run_enqueue to take a closure instead of returning a boolean. The closure is called when we previously returned true. This change allows as to run the closure in a critical section, saving the cost of locking a second time.

@bugadani bugadani force-pushed the lock_once branch 2 times, most recently from 7500f0c to 926039b Compare December 16, 2024 12:51
@bugadani bugadani marked this pull request as ready for review December 16, 2024 14:20
@Dirbaio Dirbaio added this pull request to the merge queue Dec 16, 2024
Merged via the queue into embassy-rs:main with commit 47e96be Dec 16, 2024
7 checks passed
@bugadani bugadani deleted the lock_once branch December 16, 2024 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants