Skip to content

Commit ded25ae

Browse files
committed
---
yaml --- r: 150827 b: refs/heads/try2 c: 0754d1d h: refs/heads/master i: 150825: 2f9a873 150823: 7e8ba59 v: v3
1 parent 3cfcabd commit ded25ae

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 55f02b2c1bdb6a8947478b1bdfd16423bfa7e2f5
8+
refs/heads/try2: 0754d1d061761a5f9e7fc13d45579953d329cfe1
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libgreen/lib.rs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,19 @@
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;
229242
pub mod stack;
230243
pub 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

0 commit comments

Comments
 (0)