Skip to content

Commit

Permalink
m: Use new stack listener strategy
Browse files Browse the repository at this point in the history
Signed-off-by: John Nunley <dev@notgull.net>
  • Loading branch information
notgull committed Feb 17, 2024
1 parent c5ab776 commit 4167db0
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ pub mod __private {
pub use std::rc::Rc;

use crate::{Executor, LocalExecutor};
use event_listener::{Event, EventListener};
use event_listener::Event;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
use std::thread;
Expand Down Expand Up @@ -316,19 +316,18 @@ pub mod __private {
/// Wait for the event to stop.
#[inline]
async fn wait(&self) {
let listener = EventListener::new();
futures_lite::pin!(listener);

loop {
if self.stopped.load(Ordering::Acquire) {
if self.stopped.load(Ordering::Relaxed) {
return;
}

if listener.is_listening() {
listener.as_mut().await;
} else {
listener.as_mut().listen(&self.events);
event_listener::listener!(&self.events => listener);

if self.stopped.load(Ordering::Acquire) {
return;
}

listener.await;
}
}

Expand Down

0 comments on commit 4167db0

Please sign in to comment.