Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/rustcc/coroutine-rs

Coroutine Library in Rust
https://github.com/rustcc/coroutine-rs

Last synced: 4 days ago
JSON representation

Coroutine Library in Rust

Awesome Lists containing this project

README

        

# coroutine-rs

[![Build Status](https://img.shields.io/travis/rustcc/coroutine-rs.svg)](https://travis-ci.org/rustcc/coroutine-rs) [![crates.io](https://img.shields.io/crates/v/coroutine.svg)](https://crates.io/crates/coroutine) [![crates.io](https://img.shields.io/crates/l/coroutine.svg)](https://crates.io/crates/coroutine)

[Coroutine](https://en.wikipedia.org/wiki/Coroutine) library in Rust

```toml
[dependencies]
coroutine = "0.8"
```

## Usage

Basic usage of Coroutine

```rust
extern crate coroutine;

use std::usize;
use coroutine::asymmetric::Coroutine;

fn main() {
let coro: Coroutine = Coroutine::spawn(|me,_| {
for num in 0..10 {
me.yield_with(num);
}
usize::MAX
});

for num in coro {
println!("{}", num.unwrap());
}
}
```

This program will print the following to the console

```
0
1
2
3
4
5
6
7
8
9
18446744073709551615
```

For more detail, please run `cargo doc --open`.

## Goals

- [x] Basic single threaded coroutine support

- [x] Asymmetric Coroutines

- [ ] Symmetric Coroutines

- [ ] Thread-safe: can only resume a coroutine in one thread simultaneously

## Notes

* Basically it supports arm, i686, mips, mipsel and x86_64 platforms, but we have only tested in

- OS X 10.10.*, x86_64, nightly

- ArchLinux, x86_64, nightly

## Thanks

- The Rust developers (context switch ASM from libgreen)