Created
December 28, 2013 18:19
-
-
Save anonymous/8162399 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[no_uv]; | |
extern mod native; | |
extern mod green; | |
extern mod rustuv; // pull in I/O support for libgreen | |
use std::task::TaskOpts; | |
#[start] | |
fn start(argc: int, argv: **u8) -> int { | |
do native::start(argc, argv) { | |
main(); | |
} | |
} | |
// This function runs on the main OS thread | |
fn main() { | |
let mut pool = green::SchedPool::new(green::PoolConfig::new()); | |
do pool.spawn(TaskOpts::new()) { | |
// this procedure is running on a green thread (in a pool of schedulers) | |
} | |
{ | |
// run some code on the main os thread | |
} | |
// request that the pool of schedulers shut down and then wait for all of | |
// the schedulers to exit. | |
pool.shutdown() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment