]> git.lizzy.rs Git - rust.git/commitdiff
doc: Update the runtime guide with green changes
authorAlex Crichton <alex@alexcrichton.com>
Mon, 24 Mar 2014 17:51:13 +0000 (10:51 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Mon, 24 Mar 2014 18:19:28 +0000 (11:19 -0700)
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

index 6d5d90e2617fe5f5dfbbaff0f1a85054cc0d6f4c..b52c520761e233773865cc2f7f54e0a1c5965dfb 100644 (file)
@@ -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