Skip to content

Commit 9b6f025

Browse files
committed
Rename thread_pool to task_pool
Minor change, no review. Closes #3972
1 parent a0610c9 commit 9b6f025

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/libstd/std.rc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ pub mod sync;
5454
pub mod arc;
5555
pub mod comm;
5656
pub mod future;
57-
pub mod thread_pool;
57+
pub mod task_pool;
5858

5959
// Collections
6060

src/libstd/thread_pool.rs renamed to src/libstd/task_pool.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/// A thread pool abstraction. Useful for achieving predictable CPU
1+
/// A task pool abstraction. Useful for achieving predictable CPU
22
/// parallelism.
33
44
use pipes::{Chan, Port};
@@ -9,7 +9,7 @@ enum Msg<T> {
99
Quit
1010
}
1111

12-
pub struct ThreadPool<T> {
12+
pub struct TaskPool<T> {
1313
channels: ~[Chan<Msg<T>>],
1414
mut next_index: uint,
1515

@@ -20,15 +20,15 @@ pub struct ThreadPool<T> {
2020
}
2121
}
2222

23-
pub impl<T> ThreadPool<T> {
24-
/// Spawns a new thread pool with `n_tasks` tasks. If the `sched_mode`
23+
pub impl<T> TaskPool<T> {
24+
/// Spawns a new task pool with `n_tasks` tasks. If the `sched_mode`
2525
/// is None, the tasks run on this scheduler; otherwise, they run on a
2626
/// new scheduler with the given mode. The provided `init_fn_factory`
2727
/// returns a function which, given the index of the task, should return
2828
/// local data to be kept around in that task.
2929
static fn new(n_tasks: uint,
3030
opt_sched_mode: Option<SchedMode>,
31-
init_fn_factory: ~fn() -> ~fn(uint) -> T) -> ThreadPool<T> {
31+
init_fn_factory: ~fn() -> ~fn(uint) -> T) -> TaskPool<T> {
3232
assert n_tasks >= 1;
3333

3434
let channels = do vec::from_fn(n_tasks) |i| {
@@ -59,10 +59,10 @@ pub impl<T> ThreadPool<T> {
5959
move chan
6060
};
6161

62-
return ThreadPool { channels: move channels, next_index: 0 };
62+
return TaskPool { channels: move channels, next_index: 0 };
6363
}
6464

65-
/// Executes the function `f` on a thread in the pool. The function
65+
/// Executes the function `f` on a task in the pool. The function
6666
/// receives a reference to the local data returned by the `init_fn`.
6767
fn execute(&self, f: ~fn(&T)) {
6868
self.channels[self.next_index].send(Execute(move f));
@@ -72,12 +72,12 @@ pub impl<T> ThreadPool<T> {
7272
}
7373

7474
#[test]
75-
fn test_thread_pool() {
75+
fn test_task_pool() {
7676
let f: ~fn() -> ~fn(uint) -> uint = || {
7777
let g: ~fn(uint) -> uint = |i| i;
7878
move g
7979
};
80-
let pool = ThreadPool::new(4, Some(SingleThreaded), move f);
80+
let pool = TaskPool::new(4, Some(SingleThreaded), move f);
8181
for 8.times {
8282
pool.execute(|i| io::println(fmt!("Hello from thread %u!", *i)));
8383
}

0 commit comments

Comments
 (0)