Trait polling::os::kqueue::PollerKqueueExt
source · pub trait PollerKqueueExt<F: Filter>: PollerSealed {
// Required methods
fn add_filter(&self, filter: F, key: usize, mode: PollMode) -> Result<()>;
fn modify_filter(&self, filter: F, key: usize, mode: PollMode) -> Result<()>;
fn delete_filter(&self, filter: F) -> Result<()>;
}
Expand description
Functionality that is only available for kqueue
-based platforms.
kqueue
is able to monitor much more than just read/write readiness on file descriptors. Using
this extension trait, you can monitor for signals, process exits, and more. See the implementors
of the Filter
trait for more information.
Required Methods§
sourcefn add_filter(&self, filter: F, key: usize, mode: PollMode) -> Result<()>
fn add_filter(&self, filter: F, key: usize, mode: PollMode) -> Result<()>
Add a filter to the poller.
This is similar to add
, but it allows you to specify a filter instead of
a socket. See the implementors of the Filter
trait for more information.
§Examples
use polling::{Events, Poller, PollMode};
use polling::os::kqueue::{Filter, PollerKqueueExt, Signal};
let poller = Poller::new().unwrap();
// Register the SIGINT signal.
poller.add_filter(Signal(rustix::process::Signal::Int as _), 0, PollMode::Oneshot).unwrap();
// Wait for the signal.
let mut events = Events::new();
poller.wait(&mut events, None).unwrap();
sourcefn modify_filter(&self, filter: F, key: usize, mode: PollMode) -> Result<()>
fn modify_filter(&self, filter: F, key: usize, mode: PollMode) -> Result<()>
Modify a filter in the poller.
This is similar to modify
, but it allows you to specify a filter
instead of a socket. See the implementors of the Filter
trait for more information.
§Examples
use polling::{Events, Poller, PollMode};
use polling::os::kqueue::{Filter, PollerKqueueExt, Signal};
let poller = Poller::new().unwrap();
// Register the SIGINT signal.
poller.add_filter(Signal(rustix::process::Signal::Int as _), 0, PollMode::Oneshot).unwrap();
// Re-register with a different key.
poller.modify_filter(Signal(rustix::process::Signal::Int as _), 1, PollMode::Oneshot).unwrap();
// Wait for the signal.
let mut events = Events::new();
poller.wait(&mut events, None).unwrap();
sourcefn delete_filter(&self, filter: F) -> Result<()>
fn delete_filter(&self, filter: F) -> Result<()>
Remove a filter from the poller.
This is used to remove filters that were previously added with
add_filter
.
§Examples
use polling::{Poller, PollMode};
use polling::os::kqueue::{Filter, PollerKqueueExt, Signal};
let poller = Poller::new().unwrap();
// Register the SIGINT signal.
poller.add_filter(Signal(rustix::process::Signal::Int as _), 0, PollMode::Oneshot).unwrap();
// Remove the filter.
poller.delete_filter(Signal(rustix::process::Signal::Int as _)).unwrap();