Skip to content

Commit fdfb1d9

Browse files
committed
---
yaml --- r: 152694 b: refs/heads/try2 c: af520e1 h: refs/heads/master v: v3
1 parent 6e0b2c3 commit fdfb1d9

File tree

3 files changed

+22
-32
lines changed

3 files changed

+22
-32
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: a7a18dee72f3aace13e90381139b6ccd351feef7
8+
refs/heads/try2: af520e133c24f9409f85ac91b0b8bbf033ec0b7a
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: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -67,26 +67,12 @@ li {list-style-type: none; }
6767

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

70-
# External documentation
70+
# External resources
7171

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/):
72+
* The Rust IRC channels on [irc.mozilla.org](http://irc.mozilla.org/)
8873
* [`#rust`](http://chat.mibbit.com/?server=irc.mozilla.org&channel=%23rust) - general discussion
8974
* [`#rust-gamedev`](http://chat.mibbit.com/?server=irc.mozilla.org&channel=%23rust-gamedev) - game development
9075
* [`#rust-internals`](http://chat.mibbit.com/?server=irc.mozilla.org&channel=%23rust-internals) - compiler and libraries
9176
* [`#rust-osdev`](http://chat.mibbit.com/?server=irc.mozilla.org&channel=%23rust-osdev) - operating system development
92-
77+
* The Rust community on [Reddit](http://reddit.com/r/rust)
78+
* The Rust [wiki](http://github.com/rust-lang/rust/wiki)

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+
}

0 commit comments

Comments
 (0)