Skip to content

Commit e2ae458

Browse files
committed
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.
1 parent 3ccad75 commit e2ae458

File tree

1 file changed

+27
-5
lines changed

1 file changed

+27
-5
lines changed

src/doc/guide-runtime.md

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,27 +223,49 @@ Having a default decision made in the compiler is done out of necessity and
223223
convenience. The compiler's decision of runtime to link to is *not* an
224224
endorsement of one over the other. As always, this decision can be overridden.
225225

226-
For example, this program will be linked to "the default runtime"
226+
For example, this program will be linked to "the default runtime". The current
227+
default runtime is to use libnative.
227228

228229
~~~{.rust}
229230
fn main() {}
230231
~~~
231232

232-
Whereas this program explicitly opts into using a particular runtime
233+
### Force booting with libgreen
234+
235+
In this example, the `main` function will be booted with I/O support powered by
236+
libuv. This is done by linking to the `rustuv` crate and specifying the
237+
`rustuv::event_loop` function as the event loop factory.
238+
239+
To create a pool of green tasks which have no I/O support, you may shed the
240+
`rustuv` dependency and use the `green::basic::event_loop` function instead of
241+
`rustuv::event_loop`. All tasks will have no I/O support, but they will still be
242+
able to deschedule/reschedule (use channels, locks, etc).
233243

234244
~~~{.rust}
235245
extern crate green;
246+
extern crate rustuv;
236247
237248
#[start]
238249
fn start(argc: int, argv: **u8) -> int {
239-
green::start(argc, argv, main)
250+
green::start(argc, argv, rustuv::event_loop, main)
240251
}
241252
242253
fn main() {}
243254
~~~
244255

245-
Both libgreen/libnative provide a top-level `start` function which is used to
246-
boot an initial Rust task in that specified runtime.
256+
### Force booting with libnative
257+
258+
This program's `main` function will always be booted with libnative, running
259+
inside of an OS thread.
260+
261+
~~~{.rust}
262+
extern crate native;
263+
264+
#[start]
265+
fn start(argc: int, argv: **u8) -> int { native::start(argc, argv, main) }
266+
267+
fn main() {}
268+
~~~
247269

248270
# Finding the runtime
249271

0 commit comments

Comments
 (0)