Skip to content

Commit 6a5736d

Browse files
committed
libextra: Remove ~fn() from libextra.
1 parent 500a8f1 commit 6a5736d

File tree

4 files changed

+24
-19
lines changed

4 files changed

+24
-19
lines changed

src/libextra/future.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub struct Future<A> {
3636
}
3737

3838
enum FutureState<A> {
39-
Pending(~fn() -> A),
39+
Pending(proc() -> A),
4040
Evaluating,
4141
Forced(A)
4242
}
@@ -92,7 +92,7 @@ impl<A> Future<A> {
9292
Future {state: Forced(val)}
9393
}
9494

95-
pub fn from_fn(f: ~fn() -> A) -> Future<A> {
95+
pub fn from_fn(f: proc() -> A) -> Future<A> {
9696
/*!
9797
* Create a future from a function.
9898
*
@@ -120,7 +120,7 @@ impl<A:Send> Future<A> {
120120
}
121121
}
122122

123-
pub fn spawn(blk: ~fn() -> A) -> Future<A> {
123+
pub fn spawn(blk: proc() -> A) -> Future<A> {
124124
/*!
125125
* Create a future from a unique closure.
126126
*
@@ -137,7 +137,7 @@ impl<A:Send> Future<A> {
137137
Future::from_port(port)
138138
}
139139

140-
pub fn spawn_with<B: Send>(v: B, blk: ~fn(B) -> A) -> Future<A> {
140+
pub fn spawn_with<B: Send>(v: B, blk: proc(B) -> A) -> Future<A> {
141141
/*!
142142
* Create a future from a unique closure taking one argument.
143143
*

src/libextra/task_pool.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use std::vec;
2323
#[cfg(test)] use std::task::SingleThreaded;
2424

2525
enum Msg<T> {
26-
Execute(~fn(&T)),
26+
Execute(proc(&T)),
2727
Quit
2828
}
2929

@@ -49,15 +49,15 @@ impl<T> TaskPool<T> {
4949
/// local data to be kept around in that task.
5050
pub fn new(n_tasks: uint,
5151
opt_sched_mode: Option<SchedMode>,
52-
init_fn_factory: ~fn() -> ~fn(uint) -> T)
52+
init_fn_factory: &fn() -> proc(uint) -> T)
5353
-> TaskPool<T> {
5454
assert!(n_tasks >= 1);
5555

5656
let channels = do vec::from_fn(n_tasks) |i| {
5757
let (port, chan) = comm::stream::<Msg<T>>();
5858
let init_fn = init_fn_factory();
5959

60-
let task_body: ~fn() = || {
60+
let task_body: proc() = || {
6161
let local_data = init_fn(i);
6262
loop {
6363
match port.recv() {
@@ -88,7 +88,7 @@ impl<T> TaskPool<T> {
8888

8989
/// Executes the function `f` on a task in the pool. The function
9090
/// receives a reference to the local data returned by the `init_fn`.
91-
pub fn execute(&mut self, f: ~fn(&T)) {
91+
pub fn execute(&mut self, f: proc(&T)) {
9292
self.channels[self.next_index].send(Execute(f));
9393
self.next_index += 1;
9494
if self.next_index == self.channels.len() { self.next_index = 0; }
@@ -97,8 +97,8 @@ impl<T> TaskPool<T> {
9797

9898
#[test]
9999
fn test_task_pool() {
100-
let f: ~fn() -> ~fn(uint) -> uint = || {
101-
let g: ~fn(uint) -> uint = |i| i;
100+
let f: proc() -> proc(uint) -> uint = || {
101+
let g: proc(uint) -> uint = |i| i;
102102
g
103103
};
104104
let mut pool = TaskPool::new(4, Some(SingleThreaded), f);

src/libextra/test.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,22 @@ impl TestDesc {
7474
}
7575
}
7676

77+
/// Represents a benchmark function.
78+
pub trait TDynBenchFn {
79+
fn run(&self, harness: &mut BenchHarness);
80+
}
81+
7782
// A function that runs a test. If the function returns successfully,
7883
// the test succeeds; if the function fails then the test fails. We
7984
// may need to come up with a more clever definition of test in order
8085
// to support isolation of tests into tasks.
8186
pub enum TestFn {
8287
StaticTestFn(extern fn()),
8388
StaticBenchFn(extern fn(&mut BenchHarness)),
84-
StaticMetricFn(~fn(&mut MetricMap)),
85-
DynTestFn(~fn()),
86-
DynMetricFn(~fn(&mut MetricMap)),
87-
DynBenchFn(~fn(&mut BenchHarness))
89+
StaticMetricFn(proc(&mut MetricMap)),
90+
DynTestFn(proc()),
91+
DynMetricFn(proc(&mut MetricMap)),
92+
DynBenchFn(~TDynBenchFn)
8893
}
8994

9095
impl TestFn {
@@ -859,7 +864,7 @@ pub fn run_test(force_ignore: bool,
859864

860865
fn run_test_inner(desc: TestDesc,
861866
monitor_ch: SharedChan<MonitorMsg>,
862-
testfn: ~fn()) {
867+
testfn: proc()) {
863868
let testfn_cell = ::std::cell::Cell::new(testfn);
864869
do task::spawn {
865870
let mut task = task::task();
@@ -878,8 +883,8 @@ pub fn run_test(force_ignore: bool,
878883
}
879884

880885
match testfn {
881-
DynBenchFn(benchfn) => {
882-
let bs = ::test::bench::benchmark(benchfn);
886+
DynBenchFn(bencher) => {
887+
let bs = ::test::bench::benchmark(|harness| bencher.run(harness));
883888
monitor_ch.send((desc, TrBench(bs)));
884889
return;
885890
}

src/libextra/workcache.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,14 +394,14 @@ impl<'self> Prep<'self> {
394394
pub fn exec<T:Send +
395395
Encodable<json::Encoder> +
396396
Decodable<json::Decoder>>(
397-
&'self self, blk: ~fn(&mut Exec) -> T) -> T {
397+
&'self self, blk: proc(&mut Exec) -> T) -> T {
398398
self.exec_work(blk).unwrap()
399399
}
400400

401401
fn exec_work<T:Send +
402402
Encodable<json::Encoder> +
403403
Decodable<json::Decoder>>( // FIXME(#5121)
404-
&'self self, blk: ~fn(&mut Exec) -> T) -> Work<'self, T> {
404+
&'self self, blk: proc(&mut Exec) -> T) -> Work<'self, T> {
405405
let mut bo = Some(blk);
406406

407407
debug!("exec_work: looking up {} and {:?}", self.fn_name,

0 commit comments

Comments
 (0)