[−][src]Struct wepoll_binding::Epoll
An epoll instance.
The Epoll type acts as a wrapper around wepoll's HANDLE
type, and
automatically closed it upon being dropped.
Whereas epoll on Linux supports arbitrary file descriptors, wepoll (and thus this wrapper) only supports Windows sockets.
Implementations
impl Epoll
[src]
pub fn new() -> Result<Epoll>
[src]
Creates a new Epoll
.
Flags and/or a size can not be provided, as wepoll does not support either.
Examples
use wepoll_binding::Epoll; let epoll = Epoll::new().expect("Failed to create a new Epoll");
pub fn poll(
&self,
events: &mut Events,
timeout: Option<Duration>
) -> Result<usize>
[src]
&self,
events: &mut Events,
timeout: Option<Duration>
) -> Result<usize>
Waits for events to be produced.
poll
blocks the current thread until one or more events are produced,
at which point they will be stored in the events
slice.
If a timeout is given, this method will return when it expires. When
this happens, the number of produced events may be less than the
capacity of the Events
type.
Timeouts internally use a resolution of 1 millisecond, so a timeout smaller than this value may be rounded up.
When the timeout is 0, this method won't block and report any events that are already waiting to be processed.
pub fn register<T: AsRawSocket>(
&self,
socket: &T,
flags: EventFlag,
data: u64
) -> Result<()>
[src]
&self,
socket: &T,
flags: EventFlag,
data: u64
) -> Result<()>
Registers a raw socket with self
.
Registering an already registered socket will produce an error. If you
want to update an existing registration, use Epoll::reregister()
instead.
The data
argument will be included in any events produced by the
registration.
Examples
use wepoll_binding::{Epoll, EventFlag}; use std::net::UdpSocket; let socket = UdpSocket::bind("0.0.0.0:0").unwrap(); let poll = Epoll::new().unwrap(); poll .register(&socket, EventFlag::OUT | EventFlag::ONESHOT, 42) .unwrap();
pub fn reregister<T: AsRawSocket>(
&self,
socket: &T,
flags: EventFlag,
data: u64
) -> Result<()>
[src]
&self,
socket: &T,
flags: EventFlag,
data: u64
) -> Result<()>
Re-registers a raw socket with self
.
Attempting to re-register a socket that is not registered will result in an error.
Examples
use wepoll_binding::{Epoll, EventFlag}; use std::net::UdpSocket; let socket = UdpSocket::bind("0.0.0.0:0").unwrap(); let poll = Epoll::new().unwrap(); poll .register(&socket, EventFlag::OUT | EventFlag::ONESHOT, 42) .unwrap(); poll .reregister(&socket, EventFlag::IN | EventFlag::ONESHOT, 42) .unwrap();
pub fn deregister<T: AsRawSocket>(&self, socket: &T) -> Result<()>
[src]
Deregisters a raw socket from self
.
Attempting to deregister an unregistered socket will produce an error.
Examples
use wepoll_binding::{Epoll, EventFlag}; use std::net::UdpSocket; let socket = UdpSocket::bind("0.0.0.0:0").unwrap(); let poll = Epoll::new().unwrap(); poll .register(&socket, EventFlag::OUT | EventFlag::ONESHOT, 42) .unwrap(); poll.deregister(&socket).unwrap();
Trait Implementations
impl AsRawHandle for Epoll
[src]
fn as_raw_handle(&self) -> RawHandle
[src]
impl Drop for Epoll
[src]
impl Send for Epoll
[src]
impl Sync for Epoll
[src]
Auto Trait Implementations
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>,