From e38fb19d404b7ce1802a7d880c2b619da25298d5 Mon Sep 17 00:00:00 2001 From: David Hotham Date: Mon, 25 Sep 2023 18:00:50 +0100 Subject: [PATCH] polling 3.1.0 --- Cargo.toml | 2 +- src/eventloop.rs | 15 +++------------ 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c21f124c..2a82716e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ include = ["src/**/*", "LICENSE.txt", "README.md", "CHANGELOG.md"] [dependencies] c-ares = "7.6.0" futures-channel = "0.3.9" -polling = "3.0.0" +polling = "3.1.0" [dev-dependencies] futures-executor = "0.3.9" diff --git a/src/eventloop.rs b/src/eventloop.rs index 7ae6e727..ba0989fd 100644 --- a/src/eventloop.rs +++ b/src/eventloop.rs @@ -10,6 +10,7 @@ use std::thread; use std::time::Duration; use crate::error::Error; +use polling::Event; // Indicate an interest in read and/or write events. struct Interest(bool, bool); @@ -70,7 +71,7 @@ impl EventLoop { } } else { let key = usize::try_from(socket).unwrap(); - let event = make_event(key, readable, writable); + let event = Event::new(key, readable, writable); let interest = Interest(readable, writable); if interests.insert(socket, interest).is_none() { unsafe { @@ -169,7 +170,7 @@ impl EventLoop { let interests = self.interests.lock().unwrap(); if let Some(Interest(readable, writable)) = interests.get(&socket) { let source = unsafe { borrow_socket(socket) }; - let new_event = make_event(event.key, *readable, *writable); + let new_event = Event::new(event.key, *readable, *writable); self.poller .modify(source, new_event) .expect("failed to update interest"); @@ -191,16 +192,6 @@ impl EventLoop { } } -// https://github.com/smol-rs/polling/issues/148 -fn make_event(key: usize, readable: bool, writable: bool) -> polling::Event { - match (readable, writable) { - (true, true) => polling::Event::all(key), - (true, false) => polling::Event::readable(key), - (false, true) => polling::Event::writable(key), - _ => unreachable!(), - } -} - #[cfg(unix)] unsafe fn borrow_socket(socket: c_ares::Socket) -> impl polling::AsSource { BorrowedFd::borrow_raw(socket)