epoll 0.2.2

Linux epoll wrapper
docs.rs failed to build epoll-0.2.2
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: epoll-4.3.3

epoll

Rust wrapper for Linux kernel's epoll

Documentation

Usage

extern crate epoll;

use epoll;
use epoll::util::*;
use epoll::EpollEvent;

fn start_event_loop() {
    // Create an epoll instance
    let epfd = epoll::create1(0).unwrap();

    // Add fd to epoll watch list
    let some_fd = 0 as RawFd;
    let mut event = EpollEvent {
        data: some_fd as u64,
        events: (event_type::EPOLLIN | event_type::EPOLLET | event_type::EPOLLRDHUP)
    };
    match epoll::ctl(epfd, ctl_op::ADD, some_fd, &mut event) {
        Ok(()) => println!("Fd added sucessfully"),
        Err(e) => println!("Epoll CtlError during add: {}", e)
    };

    // Epoll wait
    let mut events = Vec::<EpollEvent>::with_capacity(100);
    unsafe { events.set_len(100); }
    match epoll::wait(epfd, &mut events[..], -1) {
        Ok(num_events) => {
            println!("{} epoll event(s) received", num_events);
            for x in 0..num_events {
                // Do all the stuff
            }
        }
        Err(e) => println!("Error on epoll::wait(): {}", e)
    }
}