From: Alex Crichton Date: Mon, 24 Mar 2014 17:51:13 +0000 (-0700) Subject: doc: Update the runtime guide with green changes X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=e2ae4585481879290879e46881916ce6e3dd22c1;p=rust.git doc: Update the runtime guide with green changes This updates a few code examples about booting libgreen/libnative and also spells out how the event loop factory is required. --- diff --git a/src/doc/guide-runtime.md b/src/doc/guide-runtime.md index 6d5d90e2617..b52c520761e 100644 --- a/src/doc/guide-runtime.md +++ b/src/doc/guide-runtime.md @@ -223,27 +223,49 @@ Having a default decision made in the compiler is done out of necessity and convenience. The compiler's decision of runtime to link to is *not* an endorsement of one over the other. As always, this decision can be overridden. -For example, this program will be linked to "the default runtime" +For example, this program will be linked to "the default runtime". The current +default runtime is to use libnative. ~~~{.rust} fn main() {} ~~~ -Whereas this program explicitly opts into using a particular runtime +### Force booting with libgreen + +In this example, the `main` function will be booted with I/O support powered by +libuv. This is done by linking to the `rustuv` crate and specifying the +`rustuv::event_loop` function as the event loop factory. + +To create a pool of green tasks which have no I/O support, you may shed the +`rustuv` dependency and use the `green::basic::event_loop` function instead of +`rustuv::event_loop`. All tasks will have no I/O support, but they will still be +able to deschedule/reschedule (use channels, locks, etc). ~~~{.rust} extern crate green; +extern crate rustuv; #[start] fn start(argc: int, argv: **u8) -> int { - green::start(argc, argv, main) + green::start(argc, argv, rustuv::event_loop, main) } fn main() {} ~~~ -Both libgreen/libnative provide a top-level `start` function which is used to -boot an initial Rust task in that specified runtime. +### Force booting with libnative + +This program's `main` function will always be booted with libnative, running +inside of an OS thread. + +~~~{.rust} +extern crate native; + +#[start] +fn start(argc: int, argv: **u8) -> int { native::start(argc, argv, main) } + +fn main() {} +~~~ # Finding the runtime