Crates.io | coroutine |
lib.rs | coroutine |
version | 0.8.0 |
source | src |
created_at | 2015-04-14 11:11:59.935197 |
updated_at | 2017-03-24 17:47:17.210531 |
description | Coroutine Library in Rust |
homepage | https://github.com/rustcc/coroutine-rs |
repository | https://github.com/rustcc/coroutine-rs |
max_upload_size | |
id | 1865 |
size | 88,439 |
Coroutine library in Rust
[dependencies.coroutine]
git = "0.5.0"
Basic usage of Coroutine
extern crate coroutine;
use std::usize;
use coroutine::asymmetric::Coroutine;
fn main() {
let coro: Coroutine<i32> = 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
.
Basic single threaded coroutine support
Asymmetric Coroutines
Symmetric Coroutines
Thread-safe: can only resume a coroutine in one thread simultaneously
Currently this crate can only be built with Rust nightly because of some unstable features.
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