diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2014-02-06 13:02:06 -0800 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2014-02-06 16:45:22 -0800 |
| commit | 1508b6e953fd7f689a4ef7c0c01e989f942b695a (patch) | |
| tree | 90f4d4fdab6c9257ff25745ea3ee3f999b27ea48 /src/libnative | |
| parent | 66b9c35654d1e7716ab5ef6236c6cf308818e71c (diff) | |
| download | rust-1508b6e953fd7f689a4ef7c0c01e989f942b695a.tar.gz rust-1508b6e953fd7f689a4ef7c0c01e989f942b695a.zip | |
Add some doc examples to lib{green,native}
"How do I start in libX" is a common question that I've seen, so I figured putting the examples in as many places as possible is probably a good idea.
Diffstat (limited to 'src/libnative')
| -rw-r--r-- | src/libnative/lib.rs | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/src/libnative/lib.rs b/src/libnative/lib.rs index 1e4317af397..4840c561289 100644 --- a/src/libnative/lib.rs +++ b/src/libnative/lib.rs @@ -8,11 +8,38 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -//! The native runtime crate +//! The native I/O and threading crate //! //! This crate contains an implementation of 1:1 scheduling for a "native" //! runtime. In addition, all I/O provided by this crate is the thread blocking //! version of I/O. +//! +//! # Starting with libnative +//! +//! ```rust +//! extern mod native; +//! +//! #[start] +//! fn start(argc: int, argv: **u8) -> int { native::start(argc, argv, main) } +//! +//! fn main() { +//! // this code is running on the main OS thread +//! } +//! ``` +//! +//! # Force spawning a native task +//! +//! ```rust +//! extern mod native; +//! +//! fn main() { +//! // We're not sure whether this main function is run in 1:1 or M:N mode. +//! +//! native::task::spawn(proc() { +//! // this code is guaranteed to be run on a native thread +//! }); +//! } +//! ``` #[crate_id = "native#0.10-pre"]; #[license = "MIT/ASL2"]; |
