Skip to content

Commit

Permalink
executor: Fix issue when task is scheduled within event callback
Browse files Browse the repository at this point in the history
I believe this should be overall more correct. Previously, if the
callback taken by `process_events` scheduled a task, `process_events`
could exit with the readiness of `self.ping` cleared, but `notified` set
to `true`. In which case, future calls to `schedule` would not wake the
event source.

Fixes #171.
  • Loading branch information
ids1024 authored and notgull committed Jan 30, 2024
1 parent cd9c3f3 commit 9abedf1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/sources/futures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,6 @@ impl<T> EventSource for Executor<T> {
{
let state = &self.state;

// Set to the unnotified state.
state.sender.notified.store(false, Ordering::SeqCst);

let clear_readiness = {
let mut clear_readiness = false;

Expand Down Expand Up @@ -347,6 +344,9 @@ impl<T> EventSource for Executor<T> {
.map_err(ExecutorError::WakeError)?;
}

// Set to the unnotified state.
state.sender.notified.store(false, Ordering::SeqCst);

Ok(PostAction::Continue)
}

Expand Down

0 comments on commit 9abedf1

Please sign in to comment.