Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rustcc/coroutine-rs
Coroutine Library in Rust
https://github.com/rustcc/coroutine-rs
Last synced: 7 days ago
JSON representation
Coroutine Library in Rust
- Host: GitHub
- URL: https://github.com/rustcc/coroutine-rs
- Owner: rustcc
- License: apache-2.0
- Created: 2015-02-25T10:46:55.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2022-07-01T02:23:36.000Z (over 2 years ago)
- Last Synced: 2024-04-23T11:02:50.278Z (6 months ago)
- Language: Rust
- Size: 252 KB
- Stars: 412
- Watchers: 29
- Forks: 43
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
- awesome-rust-cn - rustcc/coroutine-rs - rs.svg">](https://travis-ci.org/rustcc/coroutine-rs) (Libraries / Concurrency)
- awesome-rust - rustcc/coroutine-rs - rs.svg">](https://travis-ci.org/rustcc/coroutine-rs) (Libraries / Concurrency)
- awesome-rust - rustcc/coroutine-rs
- awesome-rust-cn - rustcc/coroutine-rs
- awesome-rust-zh - rustcc/coroutine-rs - Rust Coroutine 库[<img src="https://img.shields.io/travis/rustcc/coroutine-rs.svg">](https://travis-ci.org/rustcc/coroutine-rs) (库 / 并发)
- awesome-rust - rustcc/coroutine-rs - Coroutine Library (Libraries / Concurrency)
- awesome-rust - rustcc/coroutine-rs - rs.svg">](https://travis-ci.org/rustcc/coroutine-rs) (库 Libraries / 并发 Concurrency)
- fucking-awesome-rust - rustcc/coroutine-rs - Coroutine Library (Libraries / Concurrency)
- fucking-awesome-rust - rustcc/coroutine-rs - Coroutine Library (Libraries / Concurrency)
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)