Skip to content

Commit bf55bd9

Browse files
committed
---
yaml --- r: 152703 b: refs/heads/try2 c: 6750eb5 h: refs/heads/master i: 152701: 791ef03 152699: f39d3d0 152695: 3aacec5 152687: 666649a 152671: a57a034 152639: 714cf90 152575: 73925e4 v: v3
1 parent cf2c538 commit bf55bd9

File tree

6 files changed

+63
-29
lines changed

6 files changed

+63
-29
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: e1038819c2ab190ace31f2f0ac7f4455e3708cfc
8+
refs/heads/try2: 6750eb5a05042fe3fb84708909074f33ad86d3ec
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/doc/index.md

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,26 @@ li {list-style-type: none; }
6767

6868
* [The `rustdoc` manual](rustdoc.html)
6969

70-
# External resources
70+
# External documentation
7171

72-
* The Rust IRC channels on [irc.mozilla.org](http://irc.mozilla.org/)
72+
*Note: While these are great resources for learning Rust, they may
73+
track a particular version of Rust that is likely not exactly the same
74+
as that for which this documentation was generated.*
75+
76+
* [Rust for Rubyists] - An excellent introduction for Rust; not just for Rubyists (tracks the most recent release).
77+
* [Rust by Example] - Short examples of common tasks in Rust (tracks the master branch).
78+
* [The Rust wiki](http://github.com/rust-lang/rust/wiki)
79+
80+
[Rust for Rubyists]: http://www.rustforrubyists.com/
81+
[Rust by Example]: http://rustbyexample.com/
82+
83+
# Community
84+
85+
* [Reddit](http://reddit.com/r/rust)
86+
* [Stack Overflow](http://stackoverflow.com/questions/tagged/rust)
87+
* The Rust IRC channels on [irc.mozilla.org](http://irc.mozilla.org/):
7388
* [`#rust`](http://chat.mibbit.com/?server=irc.mozilla.org&channel=%23rust) - general discussion
7489
* [`#rust-gamedev`](http://chat.mibbit.com/?server=irc.mozilla.org&channel=%23rust-gamedev) - game development
7590
* [`#rust-internals`](http://chat.mibbit.com/?server=irc.mozilla.org&channel=%23rust-internals) - compiler and libraries
7691
* [`#rust-osdev`](http://chat.mibbit.com/?server=irc.mozilla.org&channel=%23rust-osdev) - operating system development
77-
* The Rust community on [Reddit](http://reddit.com/r/rust)
78-
* The Rust [wiki](http://github.com/rust-lang/rust/wiki)
92+

branches/try2/src/doc/rust.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ dd {
275275

276276
nav ul {
277277
list-style-type: none;
278-
margin: 0;
278+
margin: 0 0 20px 0;
279279
padding-left: 0px;
280280
}
281281

branches/try2/src/libstd/sync/task_pool.rs

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![allow(missing_doc)]
12-
13-
/// A task pool abstraction. Useful for achieving predictable CPU
14-
/// parallelism.
11+
//! Abstraction of a task pool for basic parallelism.
1512
1613
use core::prelude::*;
1714

@@ -25,6 +22,7 @@ enum Msg<T> {
2522
Quit
2623
}
2724

25+
/// A task pool used to execute functions in parallel.
2826
pub struct TaskPool<T> {
2927
channels: Vec<Sender<Msg<T>>>,
3028
next_index: uint,
@@ -40,11 +38,13 @@ impl<T> Drop for TaskPool<T> {
4038
}
4139

4240
impl<T> TaskPool<T> {
43-
/// Spawns a new task pool with `n_tasks` tasks. If the `sched_mode`
44-
/// is None, the tasks run on this scheduler; otherwise, they run on a
45-
/// new scheduler with the given mode. The provided `init_fn_factory`
46-
/// returns a function which, given the index of the task, should return
47-
/// local data to be kept around in that task.
41+
/// Spawns a new task pool with `n_tasks` tasks. The provided
42+
/// `init_fn_factory` returns a function which, given the index of the
43+
/// task, should return local data to be kept around in that task.
44+
///
45+
/// # Failure
46+
///
47+
/// This function will fail if `n_tasks` is less than 1.
4848
pub fn new(n_tasks: uint,
4949
init_fn_factory: || -> proc(uint):Send -> T)
5050
-> TaskPool<T> {
@@ -87,12 +87,16 @@ impl<T> TaskPool<T> {
8787

8888
#[test]
8989
fn test_task_pool() {
90-
let f: || -> proc(uint):Send -> uint = || {
91-
let g: proc(uint):Send -> uint = proc(i) i;
92-
g
93-
};
90+
let f: || -> proc(uint):Send -> uint = || { proc(i) i };
9491
let mut pool = TaskPool::new(4, f);
9592
for _ in range(0, 8) {
9693
pool.execute(proc(i) println!("Hello from thread {}!", *i));
9794
}
9895
}
96+
97+
#[test]
98+
#[should_fail]
99+
fn test_zero_tasks_failure() {
100+
let f: || -> proc(uint):Send -> uint = || { proc(i) i };
101+
TaskPool::new(0, f);
102+
}

branches/try2/src/libstd/task.rs

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,33 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
//! Utilities for managing and scheduling tasks
11+
//! Task creation
1212
//!
13-
//! An executing Rust program consists of a collection of lightweight tasks,
14-
//! each with their own stack. Tasks communicate with each other using channels
15-
//! (see `std::comm`) or other forms of synchronization (see `std::sync`) that
16-
//! ensure data-race freedom.
13+
//! An executing Rust program consists of a collection of tasks, each
14+
//! with their own stack and local state. A Rust task is typically
15+
//! backed by an operating system thread, making tasks 'just threads',
16+
//! but may also be implemented via other strategies as well
17+
//! (e.g. Rust comes with the [`green`](../../green/index.html)
18+
//! scheduling crate for creating tasks backed by green threads).
1719
//!
18-
//! Failure in one task does immediately propagate to any others (not to parent,
19-
//! not to child). Failure propagation is instead handled as part of task
20-
//! synchronization. For example, the channel `send()` and `recv()` methods will
21-
//! fail if the other end has hung up already.
20+
//! Tasks generally have their memory *isolated* from each other by
21+
//! virtue of Rust's owned types (which of course may only be owned by
22+
//! a single task at a time). Communication between tasks is primarily
23+
//! done through [channels](../../std/comm/index.html), Rust's
24+
//! message-passing types, though [other forms of task
25+
//! synchronization](../../std/sync/index.html) are often employed to
26+
//! achieve particular performance goals. In particular, types that
27+
//! are guaranteed to be threadsafe are easily shared between threads
28+
//! using the atomically-reference-counted container,
29+
//! [`Arc`](../../std/sync/struct.Arc.html).
30+
//!
31+
//! Fatal logic errors in Rust cause *task failure*, during which
32+
//! a task will unwind the stack, running destructors and freeing
33+
//! owned resources. Task failure is unrecoverable from within
34+
//! the failing task (i.e. there is no 'try/catch' in Rust), but
35+
//! failure may optionally be detected from a different task. If
36+
//! the main task fails the application will exit with a non-zero
37+
//! exit code.
2238
//!
2339
//! # Basic task scheduling
2440
//!

branches/try2/src/libsync/comm/select.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ impl Select {
132132
/// event could either be that data is available or the corresponding
133133
/// channel has been closed.
134134
pub fn wait(&self) -> uint {
135-
self.wait2(false)
135+
self.wait2(true)
136136
}
137137

138138
/// Helper method for skipping the preflight checks during testing

0 commit comments

Comments
 (0)