@@ -223,27 +223,49 @@ Having a default decision made in the compiler is done out of necessity and
223
223
convenience. The compiler's decision of runtime to link to is * not* an
224
224
endorsement of one over the other. As always, this decision can be overridden.
225
225
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.
227
228
228
229
~~~ {.rust}
229
230
fn main() {}
230
231
~~~
231
232
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).
233
243
234
244
~~~ {.rust}
235
245
extern crate green;
246
+ extern crate rustuv;
236
247
237
248
#[start]
238
249
fn start(argc: int, argv: **u8) -> int {
239
- green::start(argc, argv, main)
250
+ green::start(argc, argv, rustuv::event_loop, main)
240
251
}
241
252
242
253
fn main() {}
243
254
~~~
244
255
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
+ ~~~
247
269
248
270
# Finding the runtime
249
271
0 commit comments