Giter Club home page Giter Club logo

event_rust's Introduction

Event - Async IO similar to libevent

Event is a lightweight IO library for Rust with a focus on adding as little overhead as possible over the OS abstractions.

Build Status

Getting started guide Currently a work in progress:

Usage

To use event_rust, first add this to your Cargo.toml:

[dependencies]
event_rust = "0.1.1"

Then, add this to your crate root:

extern crate event_rust;

Add empty event just do

extern crate event_rust;
use event_rust::EventLoop;

fn main() {
    let mut event_loop = EventLoop::new().unwrap();
    event_loop.run();
}

Add simple timer event just do

extern crate event_rust;
use event_rust::{EventLoop, EventEntry, EventFlags};
use std::ptr;

fn time_callback(ev : *mut EventLoop, fd : u64, _ : EventFlags, data : *mut ()) -> i32 {
    println!("fd is {:?}", fd);
    //return 0 status ok other will delete the timer
    0
}

pub fn main() {
    let mut event_loop : EventLoop = EventLoop::new().unwrap();
    event_loop.add_timer(EventEntry::new_timer(100, false, Some(time_callback), Some( ptr::null_mut() )));
    event_loop.add_timer(EventEntry::new_timer(200, true, Some(time_callback), Some( ptr::null_mut() )));
    event_loop.run().unwrap();
}

Features

  • Event loop backed by epoll, windows by select.
  • Non-blocking TCP sockets
  • High performance timer system

Platforms

Currently, event_rust only supports Linux and Windows. The goal is to support all platforms that support Rust and the readiness IO model.

event_rust's People

Contributors

tickbh avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.