From e2ae4585481879290879e46881916ce6e3dd22c1 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 24 Mar 2014 10:51:13 -0700 Subject: [PATCH] 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. --- src/doc/guide-runtime.md | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) 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 -- 2.44.0