open-coroutine

What is open-coroutine ?

The open-coroutine is a simple, efficient and generic stackful-coroutine library.

Status

Still under development, please do not use this library in the production environment !

Only support hook several system calls.

Features

0.1.0

How to use this library ?

step1

add dependency to your Cargo.toml ```toml [dependencies]

check https://crates.io/crates/open-coroutine

open-coroutine = "x.y.z" ```

step2

enable hooks rust fn main() { //step2 enable hooks open_coroutine::init(); //...... }

step3

enjoy the performance improvement brought by open-coroutine !

simplest example below

```rust use opencoroutine::{co, Yielder}; use std::os::raw::cvoid; use std::time::Duration;

extern "C" fn f1( yielder: &Yielder, (), Option<&'static mut cvoid>>, input: Option<&'static mut cvoid>, ) -> Option<&'static mut c_void> { println!("[coroutine1] launched"); None }

extern "C" fn f2( yielder: &Yielder, (), Option<&'static mut cvoid>>, input: Option<&'static mut cvoid>, ) -> Option<&'static mut c_void> { println!("[coroutine2] launched"); None }

fn main() { // because we used opencoroutine::co() // we don't need to call opencoroutine::init() // otherwise, don't forget opencoroutine::init() co(f1, None, 4096); co(f2, None, 4096); std::thread::sleep(Duration::frommillis(1)); println!("scheduler finished successfully!"); } ```

How to run examples ?

shell cargo run --example hello