File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change 144144//! }
145145//! ```
146146//!
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+ //!
147160//! # Using a scheduler pool
148161//!
149162//! ```rust
@@ -229,6 +242,33 @@ pub mod sleeper_list;
229242pub mod stack;
230243pub mod task;
231244
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+
232272/// Set up a default runtime configuration, given compiler-supplied arguments.
233273///
234274/// 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