https://github.com/tickbh/td_revent
tickdream rust event - Async IO similar to libevent
https://github.com/tickbh/td_revent
asyncio libevent rust rust-event td-revent
Last synced: 3 months ago
JSON representation
tickdream rust event - Async IO similar to libevent
- Host: GitHub
- URL: https://github.com/tickbh/td_revent
- Owner: tickbh
- License: apache-2.0
- Created: 2016-02-25T01:59:25.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2022-05-13T12:10:55.000Z (over 3 years ago)
- Last Synced: 2025-09-01T02:01:55.088Z (4 months ago)
- Topics: asyncio, libevent, rust, rust-event, td-revent
- Language: Rust
- Homepage:
- Size: 159 KB
- Stars: 11
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# 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.
[](https://travis-ci.org/tickbh/td_revent)
Getting started guide Currently a work in progress:
##Usage
To use td_revent, first add this to your Cargo.toml:
```rust
[dependencies]
td_revent = "0.3.0"
```
Then, add this to your crate root:
```rust
extern crate td_revent;
```
Add empty event just do
```rust
extern crate td_revent;
use td_revent::EventLoop;
fn main() {
let mut event_loop = EventLoop::new().unwrap();
event_loop.run();
}
```
Add simple timer event just do
```rust
extern crate td_revent;
use td_revent::{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), None));
event_loop.add_timer(EventEntry::new_timer(200, true, Some(time_callback), None));
event_loop.run().unwrap();
}
```
##Features
Event loop backed by epoll, windows by select.
Non-blocking TCP sockets
High performance timer system
##Platforms
Currently, td_revent only supports Linux and Windows. The goal is to support all platforms that support Rust and the readiness IO model.