about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2013-11-18 15:39:02 -0800
committerPatrick Walton <pcwalton@mimiga.net>2013-11-18 18:27:30 -0800
commit6a5736d704d46e11fa06f7943d01b6744146b140 (patch)
tree4109d8fefa07f612db8849f5ca75f3a25f0821e3
parent500a8f15c9afdd4e98e1d1573e34dd2b948f9773 (diff)
downloadrust-6a5736d704d46e11fa06f7943d01b6744146b140.tar.gz
rust-6a5736d704d46e11fa06f7943d01b6744146b140.zip
libextra: Remove `~fn()` from libextra.
-rw-r--r--src/libextra/future.rs8
-rw-r--r--src/libextra/task_pool.rs12
-rw-r--r--src/libextra/test.rs19
-rw-r--r--src/libextra/workcache.rs4
4 files changed, 24 insertions, 19 deletions
diff --git a/src/libextra/future.rs b/src/libextra/future.rs
index 8f28be49782..640ced24bad 100644
--- a/src/libextra/future.rs
+++ b/src/libextra/future.rs
@@ -36,7 +36,7 @@ pub struct Future<A> {
 }
 
 enum FutureState<A> {
-    Pending(~fn() -> A),
+    Pending(proc() -> A),
     Evaluating,
     Forced(A)
 }
@@ -92,7 +92,7 @@ impl<A> Future<A> {
         Future {state: Forced(val)}
     }
 
-    pub fn from_fn(f: ~fn() -> A) -> Future<A> {
+    pub fn from_fn(f: proc() -> A) -> Future<A> {
         /*!
          * Create a future from a function.
          *
@@ -120,7 +120,7 @@ impl<A:Send> Future<A> {
         }
     }
 
-    pub fn spawn(blk: ~fn() -> A) -> Future<A> {
+    pub fn spawn(blk: proc() -> A) -> Future<A> {
         /*!
          * Create a future from a unique closure.
          *
@@ -137,7 +137,7 @@ impl<A:Send> Future<A> {
         Future::from_port(port)
     }
 
-    pub fn spawn_with<B: Send>(v: B, blk: ~fn(B) -> A) -> Future<A> {
+    pub fn spawn_with<B: Send>(v: B, blk: proc(B) -> A) -> Future<A> {
         /*!
          * Create a future from a unique closure taking one argument.
          *
diff --git a/src/libextra/task_pool.rs b/src/libextra/task_pool.rs
index f7db66dc4e0..2ee3daacf80 100644
--- a/src/libextra/task_pool.rs
+++ b/src/libextra/task_pool.rs
@@ -23,7 +23,7 @@ use std::vec;
 #[cfg(test)] use std::task::SingleThreaded;
 
 enum Msg<T> {
-    Execute(~fn(&T)),
+    Execute(proc(&T)),
     Quit
 }
 
@@ -49,7 +49,7 @@ impl<T> TaskPool<T> {
     /// local data to be kept around in that task.
     pub fn new(n_tasks: uint,
                opt_sched_mode: Option<SchedMode>,
-               init_fn_factory: ~fn() -> ~fn(uint) -> T)
+               init_fn_factory: &fn() -> proc(uint) -> T)
                -> TaskPool<T> {
         assert!(n_tasks >= 1);
 
@@ -57,7 +57,7 @@ impl<T> TaskPool<T> {
             let (port, chan) = comm::stream::<Msg<T>>();
             let init_fn = init_fn_factory();
 
-            let task_body: ~fn() = || {
+            let task_body: proc() = || {
                 let local_data = init_fn(i);
                 loop {
                     match port.recv() {
@@ -88,7 +88,7 @@ impl<T> TaskPool<T> {
 
     /// Executes the function `f` on a task in the pool. The function
     /// receives a reference to the local data returned by the `init_fn`.
-    pub fn execute(&mut self, f: ~fn(&T)) {
+    pub fn execute(&mut self, f: proc(&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,8 +97,8 @@ impl<T> TaskPool<T> {
 
 #[test]
 fn test_task_pool() {
-    let f: ~fn() -> ~fn(uint) -> uint = || {
-        let g: ~fn(uint) -> uint = |i| i;
+    let f: proc() -> proc(uint) -> uint = || {
+        let g: proc(uint) -> uint = |i| i;
         g
     };
     let mut pool = TaskPool::new(4, Some(SingleThreaded), f);
diff --git a/src/libextra/test.rs b/src/libextra/test.rs
index 14fee38dada..acb3d538c98 100644
--- a/src/libextra/test.rs
+++ b/src/libextra/test.rs
@@ -74,6 +74,11 @@ impl TestDesc {
     }
 }
 
+/// Represents a benchmark function.
+pub trait TDynBenchFn {
+    fn run(&self, harness: &mut BenchHarness);
+}
+
 // A function that runs a test. If the function returns successfully,
 // the test succeeds; if the function fails then the test fails. We
 // may need to come up with a more clever definition of test in order
@@ -81,10 +86,10 @@ impl TestDesc {
 pub enum TestFn {
     StaticTestFn(extern fn()),
     StaticBenchFn(extern fn(&mut BenchHarness)),
-    StaticMetricFn(~fn(&mut MetricMap)),
-    DynTestFn(~fn()),
-    DynMetricFn(~fn(&mut MetricMap)),
-    DynBenchFn(~fn(&mut BenchHarness))
+    StaticMetricFn(proc(&mut MetricMap)),
+    DynTestFn(proc()),
+    DynMetricFn(proc(&mut MetricMap)),
+    DynBenchFn(~TDynBenchFn)
 }
 
 impl TestFn {
@@ -859,7 +864,7 @@ pub fn run_test(force_ignore: bool,
 
     fn run_test_inner(desc: TestDesc,
                       monitor_ch: SharedChan<MonitorMsg>,
-                      testfn: ~fn()) {
+                      testfn: proc()) {
         let testfn_cell = ::std::cell::Cell::new(testfn);
         do task::spawn {
             let mut task = task::task();
@@ -878,8 +883,8 @@ pub fn run_test(force_ignore: bool,
     }
 
     match testfn {
-        DynBenchFn(benchfn) => {
-            let bs = ::test::bench::benchmark(benchfn);
+        DynBenchFn(bencher) => {
+            let bs = ::test::bench::benchmark(|harness| bencher.run(harness));
             monitor_ch.send((desc, TrBench(bs)));
             return;
         }
diff --git a/src/libextra/workcache.rs b/src/libextra/workcache.rs
index 89e50f53ab4..02855eb9777 100644
--- a/src/libextra/workcache.rs
+++ b/src/libextra/workcache.rs
@@ -394,14 +394,14 @@ impl<'self> Prep<'self> {
     pub fn exec<T:Send +
         Encodable<json::Encoder> +
         Decodable<json::Decoder>>(
-            &'self self, blk: ~fn(&mut Exec) -> T) -> T {
+            &'self self, blk: proc(&mut Exec) -> T) -> T {
         self.exec_work(blk).unwrap()
     }
 
     fn exec_work<T:Send +
         Encodable<json::Encoder> +
         Decodable<json::Decoder>>( // FIXME(#5121)
-            &'self self, blk: ~fn(&mut Exec) -> T) -> Work<'self, T> {
+            &'self self, blk: proc(&mut Exec) -> T) -> Work<'self, T> {
         let mut bo = Some(blk);
 
         debug!("exec_work: looking up {} and {:?}", self.fn_name,