An open API service indexing awesome lists of open source software.

https://github.com/dpc/mioco.pre-0.9

Scalable, coroutine-based, asynchronous IO handling library for Rust programming language. (aka MIO COroutines).
https://github.com/dpc/mioco.pre-0.9

Last synced: about 1 year ago
JSON representation

Scalable, coroutine-based, asynchronous IO handling library for Rust programming language. (aka MIO COroutines).

Awesome Lists containing this project

README

          

# mioco



Travis CI Build Status


App Veyor Build Status


crates.io


Gitter Chat



Documentation

## Project status

This is repository for mioco before version 0.9. It's hear for historical reasons, while
I've started reworking mioco in the original location: https://github.com/dpc/mioco .
Sorry for all the confusion.

Rust community decided that `futures` should be main Rust async IO story, so you
might want to look at
[tokio-fiber: coroutines as `Future`s](https://github.com/dpc/tokio-fiber/)
project, which should have mioco-like API and allow easily porting code using `mioco`.

## Code snippet

``` rust
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](BENCHMARKS.md).

## Contributors welcome!

Mioco is looking for contributors. See
[Contributing page](https://github.com/dpc/mioco/wiki/Contributing)
for details.

## Introduction

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][green threads] on top of [`mio`][mio]*.

Read [Documentation](//dpc.github.io/mioco/) for details and features.

If you want to say hi, or need help use [#mioco gitter.im][mioco gitter].

To report a bug or ask for features use [github issues][issues].

[rust]: http://rust-lang.org
[mio]: //github.com/carllerche/mio
[colerr]: //github.com/dpc/colerr
[mioco gitter]: https://gitter.im/dpc/mioco
[rust user forum]: https://users.rust-lang.org/
[issues]: //github.com/dpc/mioco/issues
[green threads]: https://en.wikipedia.org/wiki/Green_threads

## Building & running

### Standalone

To start test echo server:

cargo run --release --example echo

For daily work:

make all

[multirust]: https://github.com/brson/multirust

### In your project

In Cargo.toml:

```
[dependencies]
mioco = "*"
```

In your `main.rs`:

```
#[macro_use]
extern crate mioco;
```

## Projects using mioco:

* [colerr][colerr] - colorize stderr;
* [mioco-openssl example](https://github.com/sp3d/mioco-openssl-example)

Send PR or drop a link on gitter.