[−][src]Struct poller::Poller
定义文件 I/O 事件通知器。
每个实例可以管理多个 fd
的 I/O 事件。
Implementations
impl Poller
[src]
pub fn new() -> Result<Self, SysError>
[src]
创建一个新的 I/O 事件通知器。
pub fn add(
&mut self,
fd: i32,
events: Events,
ctx: Option<EventContext>
) -> Result<(), SysError>
[src]
&mut self,
fd: i32,
events: Events,
ctx: Option<EventContext>
) -> Result<(), SysError>
添加一个文件描述符到监视列表中。
注意: 此函数不会把 fd
的所有权转移到 Poller
内,请确保在 Poller
活动期内 fd
都是可用的。
pub fn remove(&mut self, fd: i32) -> Result<(), SysError>
[src]
将一个文件描述符从监视列表中移除。
pub fn pull_events(
&self,
timeout_ms: i32
) -> Result<Vec<EventData<'_>>, SysError>
[src]
&self,
timeout_ms: i32
) -> Result<Vec<EventData<'_>>, SysError>
拉取所有被监测到的 I/O 事件。
Examples
use poller::{Events, Poller}; let mut poller = Poller::new().unwrap(); poller.add(1, Events::new().with_write(), None).unwrap(); for (fd, events, ctx) in poller.pull_events(1000).unwrap().iter() { println!("Fd={}, Events={}, Context={:?}", fd, events, ctx); }
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Poller
impl Send for Poller
impl Sync for Poller
impl Unpin for Poller
impl !UnwindSafe for Poller
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,