libextra: Remove ~fn()
from libextra.
This commit is contained in:
parent
500a8f15c9
commit
6a5736d704
@ -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.
|
||||
*
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user