mirror of
https://github.com/danog/ext-php-rs.git
synced 2024-11-30 04:39:04 +01:00
Remove redundant fclose
This commit is contained in:
parent
ca2bc9ae97
commit
8514614521
@ -15,7 +15,7 @@ use lazy_static::lazy_static;
|
||||
use tokio::runtime::Runtime;
|
||||
use std::os::fd::AsRawFd;
|
||||
|
||||
use super::borrow_unchecked;
|
||||
use super::{borrow_unchecked, printf};
|
||||
|
||||
lazy_static! {
|
||||
pub static ref RUNTIME: Runtime = Runtime::new().expect("Could not allocate runtime");
|
||||
@ -87,7 +87,17 @@ impl EventLoop {
|
||||
|
||||
pub fn wakeup() -> PhpResult<()> {
|
||||
EVENTLOOP.with_borrow_mut(|c| {
|
||||
c.as_mut().unwrap().wakeup_internal()
|
||||
let c = c.as_mut().unwrap();
|
||||
|
||||
c.notify_receiver.read_exact(&mut c.dummy).unwrap();
|
||||
|
||||
for fiber_id in c.receiver.try_iter() {
|
||||
if let Some(fiber) = c.fibers.get_index_mut(fiber_id) {
|
||||
fiber.object_mut().unwrap().try_call_method("resume", vec![])?;
|
||||
c.fibers.remove_index(fiber_id);
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
|
||||
@ -113,23 +123,4 @@ impl EventLoop {
|
||||
get_current_suspension: Function::try_from_method("\\Revolt\\EventLoop", "getSuspension").ok_or("\\Revolt\\EventLoop::getSuspension does not exist")?,
|
||||
})
|
||||
}
|
||||
|
||||
fn wakeup_internal(&mut self) -> PhpResult<()> {
|
||||
self.notify_receiver.read_exact(&mut self.dummy).unwrap();
|
||||
|
||||
for fiber_id in self.receiver.try_iter() {
|
||||
if let Some(fiber) = self.fibers.get_index_mut(fiber_id) {
|
||||
fiber.object_mut().unwrap().try_call_method("resume", vec![])?;
|
||||
self.fibers.remove_index(fiber_id);
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for EventLoop {
|
||||
fn drop(&mut self) {
|
||||
unsafe { libc::close(self.notify_receiver.as_raw_fd()) };
|
||||
unsafe { libc::close(self.notify_sender.as_raw_fd()) };
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user