m: Port to event-listener v5.0.0

cc smol-rs/event-listener#104

Signed-off-by: John Nunley <dev@notgull.net>
This commit is contained in:
John Nunley 2024-02-12 06:26:10 -08:00 committed by GitHub
parent d23ab0b6a3
commit 35a77ff266
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 12 deletions

View File

@ -17,7 +17,7 @@ exclude = ["/.*"]
[dependencies]
async-lock = "3.0.0"
cfg-if = "1.0"
event-listener = "4.0.0"
event-listener = "5.0.0"
futures-lite = "2.0.0"
[target.'cfg(unix)'.dependencies]

View File

@ -76,7 +76,7 @@ use std::os::unix::io::{AsFd, AsRawFd, BorrowedFd, OwnedFd, RawFd};
use blocking::Unblock;
use async_lock::{Mutex as AsyncMutex, OnceCell};
use event_listener::{Event, EventListener};
use event_listener::Event;
use futures_lite::{future, io, prelude::*};
#[doc(no_inline)]
@ -510,22 +510,22 @@ impl Child {
let child = self.child.clone();
async move {
let listener = EventListener::new();
let mut listening = false;
futures_lite::pin!(listener);
loop {
// Wait on the child process.
if let Some(status) = child.lock().unwrap().get_mut().try_wait()? {
return Ok(status);
}
if listening {
listener.as_mut().await;
listening = false;
} else {
listener.as_mut().listen(&Reaper::get().sigchld);
listening = true;
// Start listening.
event_listener::listener!(Reaper::get().sigchld => listener);
// Try again.
if let Some(status) = child.lock().unwrap().get_mut().try_wait()? {
return Ok(status);
}
// Wait on the listener.
listener.await;
}
}
}