File tree 1 file changed +40
-0
lines changed
1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change 144
144
//! }
145
145
//! ```
146
146
//!
147
+ //! The above code can also be shortened with a macro from libgreen.
148
+ //!
149
+ //! ```
150
+ //! #![feature(phase)]
151
+ //! #[phase(syntax)] extern crate green;
152
+ //!
153
+ //! green_start!(main)
154
+ //!
155
+ //! fn main() {
156
+ //! // run inside of a green pool
157
+ //! }
158
+ //! ```
159
+ //!
147
160
//! # Using a scheduler pool
148
161
//!
149
162
//! ```rust
@@ -229,6 +242,33 @@ pub mod sleeper_list;
229
242
pub mod stack;
230
243
pub mod task;
231
244
245
+ /// A helper macro for booting a program with libgreen
246
+ ///
247
+ /// # Example
248
+ ///
249
+ /// ```
250
+ /// #![feature(phase)]
251
+ /// #[phase(syntax)] extern crate green;
252
+ ///
253
+ /// green_start!(main)
254
+ ///
255
+ /// fn main() {
256
+ /// // running with libgreen
257
+ /// }
258
+ /// ```
259
+ #[ macro_export]
260
+ macro_rules! green_start( ( $f: ident) => (
261
+ mod __start {
262
+ extern crate green;
263
+ extern crate rustuv;
264
+
265
+ #[ start]
266
+ fn start( argc: int, argv: * * u8 ) -> int {
267
+ green:: start( argc, argv, rustuv:: event_loop, super :: $f)
268
+ }
269
+ }
270
+ ) )
271
+
232
272
/// Set up a default runtime configuration, given compiler-supplied arguments.
233
273
///
234
274
/// This function will block until the entire pool of M:N schedulers have
You can’t perform that action at this time.
0 commit comments