From 3136fba5aeca9184c944829596b93e45886fecf2 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Sun, 24 Mar 2013 12:41:19 -0400 Subject: Removing some mutable fields in libstd --- src/libstd/task_pool.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/libstd/task_pool.rs') diff --git a/src/libstd/task_pool.rs b/src/libstd/task_pool.rs index aed6721b78e..3f2772942a5 100644 --- a/src/libstd/task_pool.rs +++ b/src/libstd/task_pool.rs @@ -26,8 +26,7 @@ enum Msg { pub struct TaskPool { channels: ~[Chan>], - mut next_index: uint, - + next_index: uint, } #[unsafe_destructor] @@ -84,7 +83,7 @@ pub impl TaskPool { /// Executes the function `f` on a task in the pool. The function /// receives a reference to the local data returned by the `init_fn`. - fn execute(&self, f: ~fn(&T)) { + fn execute(&mut self, f: ~fn(&T)) { self.channels[self.next_index].send(Execute(f)); self.next_index += 1; if self.next_index == self.channels.len() { self.next_index = 0; } @@ -97,7 +96,7 @@ fn test_task_pool() { let g: ~fn(uint) -> uint = |i| i; g }; - let pool = TaskPool::new(4, Some(SingleThreaded), f); + let mut pool = TaskPool::new(4, Some(SingleThreaded), f); for 8.times { pool.execute(|i| io::println(fmt!("Hello from thread %u!", *i))); } -- cgit 1.4.1-3-g733a5