coroutine-rs

Crates.iocoroutine-rs
lib.rscoroutine-rs
version0.0.1
sourcesrc
created_at2015-04-13 08:06:00.291996
updated_at2015-12-11 23:58:10.571132
descriptionCoroutine Library in Rust
homepagehttps://github.com/rustcc/coroutine-rs
repositoryhttps://github.com/rustcc/coroutine-rs
max_upload_size
id1857
size92,280
ty (zonyitoo)

documentation

README

coroutine-rs Build Status

Coroutine library in Rust

[dependencies.coroutine-rs]
git = "https://github.com/rustcc/coroutine-rs.git"

Usage

Basic usage of Coroutine

extern crate coroutine;

use coroutine::coroutine::{spawn, sched};

fn main() {
    // Spawn a new coroutine
    let coro = spawn(move|| {

        println!("Hello in coroutine!");

        // Yield back to it's parent
        sched();

        println!("We are back!!");

        // Spawn a new coroutine
        spawn(move|| {
            println!("Hello inside");
        }).join().unwrap();

        println!("Good bye");
    });

    coro.resume().unwrap();

    println!("We are here!");

    // Resume the coroutine
    coro.resume().unwrap();

    println!("Back to main.");
}

Goals

  • Basic single threaded coroutine support

  • Clonable coroutine handle

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

  • Multithreaded scheduler with work stealing feature

  • Asynchronous I/O supports

Commit count: 219

cargo fmt