File tree Expand file tree Collapse file tree 2 files changed +41
-1
lines changed
branches/try2/src/libgreen Expand file tree Collapse file tree 2 files changed +41
-1
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
5
5
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
6
6
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
7
7
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8
- refs/heads/try2: 55f02b2c1bdb6a8947478b1bdfd16423bfa7e2f5
8
+ refs/heads/try2: 0754d1d061761a5f9e7fc13d45579953d329cfe1
9
9
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
10
10
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
11
11
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
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