coroutine 0.1.2

Coroutine Library in Rust
docs.rs failed to build coroutine-0.1.2
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: coroutine-0.8.0

coroutine-rs

Build Status

Coroutine library in Rust

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

or

[dependencies]
coroutine = "*"

Usage

Basic usage of Coroutine

extern crate coroutine;

use 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