Skip to content

Instantly share code, notes, and snippets.

Created December 28, 2013 18:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/8162399 to your computer and use it in GitHub Desktop.
Save anonymous/8162399 to your computer and use it in GitHub Desktop.
#[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