Skip to content

Commit

Permalink
reset woken of outer future after polled
Browse files Browse the repository at this point in the history
  • Loading branch information
suikammd committed Oct 7, 2021
1 parent d047584 commit bb720b1
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions tokio/src/runtime/basic_scheduler.rs
Expand Up @@ -224,7 +224,7 @@ impl<P: Park> Inner<P> {
pin!(future);

'outer: loop {
if scheduler.spawner.was_woken() || !polled {
if scheduler.spawner.reset_woken() || !polled {
polled = true;
scheduler.stats.incr_poll_count();
if let Ready(v) = crate::coop::budget(|| future.as_mut().poll(&mut cx)) {
Expand Down Expand Up @@ -423,8 +423,9 @@ impl Spawner {
waker_ref(&self.shared)
}

fn was_woken(&self) -> bool {
self.shared.woken.load(Acquire)
// reset woken to false and return original value
fn reset_woken(&self) -> bool {
self.shared.woken.swap(false, AcqRel)
}
}

Expand Down

0 comments on commit bb720b1

Please sign in to comment.