Crates.io | mioco |
lib.rs | mioco |
version | 0.8.1 |
source | src |
created_at | 2015-07-04 18:49:19.5616 |
updated_at | 2016-08-21 23:44:40.351373 |
description | Scalable, asynchronous IO coroutine-based handling (aka MIO COroutines). |
homepage | https://github.com/dpc/mioco |
repository | https://github.com/dpc/mioco |
max_upload_size | |
id | 2530 |
size | 202,136 |
mioco::start(|| -> io::Result<()> {
let addr = listend_addr();
let listener = try!(TcpListener::bind(&addr));
println!("Starting tcp echo server on {:?}", try!(listener.local_addr()));
loop {
let mut conn = try!(listener.accept());
mioco::spawn(move || -> io::Result<()> {
let mut buf = [0u8; 1024 * 16];
loop {
let size = try!(conn.read(&mut buf));
if size == 0 {/* eof */ break; }
let _ = try!(conn.write_all(&mut buf[0..size]));
}
Ok(())
});
}
}).unwrap().unwrap();
This trivial code scales very well. See benchmarks.
Mioco is looking for contributors. See Contributing page for details.
Scalable, coroutine-based, asynchronous IO handling library for Rust programming language.
Mioco uses asynchronous event loop, to cooperatively switch between
coroutines (aka. green threads), depending on data availability. You
can think of mioco
as Node.js for Rust or Rust green
threads on top of mio
.
Read Documentation for details and features.
If you want to say hi, or need help use #mioco gitter.im.
To report a bug or ask for features use github issues.
To start test echo server:
cargo run --release --example echo
For daily work:
make all
In Cargo.toml:
[dependencies]
mioco = "*"
In your main.rs
:
#[macro_use]
extern crate mioco;
Send PR or drop a link on gitter.