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> {
|
enum FutureState<A> {
|
||||||
Pending(~fn() -> A),
|
Pending(proc() -> A),
|
||||||
Evaluating,
|
Evaluating,
|
||||||
Forced(A)
|
Forced(A)
|
||||||
}
|
}
|
||||||
@ -92,7 +92,7 @@ impl<A> Future<A> {
|
|||||||
Future {state: Forced(val)}
|
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.
|
* 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.
|
* Create a future from a unique closure.
|
||||||
*
|
*
|
||||||
@ -137,7 +137,7 @@ impl<A:Send> Future<A> {
|
|||||||
Future::from_port(port)
|
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.
|
* Create a future from a unique closure taking one argument.
|
||||||
*
|
*
|
||||||
|
@ -23,7 +23,7 @@ use std::vec;
|
|||||||
#[cfg(test)] use std::task::SingleThreaded;
|
#[cfg(test)] use std::task::SingleThreaded;
|
||||||
|
|
||||||
enum Msg<T> {
|
enum Msg<T> {
|
||||||
Execute(~fn(&T)),
|
Execute(proc(&T)),
|
||||||
Quit
|
Quit
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ impl<T> TaskPool<T> {
|
|||||||
/// local data to be kept around in that task.
|
/// local data to be kept around in that task.
|
||||||
pub fn new(n_tasks: uint,
|
pub fn new(n_tasks: uint,
|
||||||
opt_sched_mode: Option<SchedMode>,
|
opt_sched_mode: Option<SchedMode>,
|
||||||
init_fn_factory: ~fn() -> ~fn(uint) -> T)
|
init_fn_factory: &fn() -> proc(uint) -> T)
|
||||||
-> TaskPool<T> {
|
-> TaskPool<T> {
|
||||||
assert!(n_tasks >= 1);
|
assert!(n_tasks >= 1);
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ impl<T> TaskPool<T> {
|
|||||||
let (port, chan) = comm::stream::<Msg<T>>();
|
let (port, chan) = comm::stream::<Msg<T>>();
|
||||||
let init_fn = init_fn_factory();
|
let init_fn = init_fn_factory();
|
||||||
|
|
||||||
let task_body: ~fn() = || {
|
let task_body: proc() = || {
|
||||||
let local_data = init_fn(i);
|
let local_data = init_fn(i);
|
||||||
loop {
|
loop {
|
||||||
match port.recv() {
|
match port.recv() {
|
||||||
@ -88,7 +88,7 @@ impl<T> TaskPool<T> {
|
|||||||
|
|
||||||
/// Executes the function `f` on a task in the pool. The function
|
/// Executes the function `f` on a task in the pool. The function
|
||||||
/// receives a reference to the local data returned by the `init_fn`.
|
/// 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.channels[self.next_index].send(Execute(f));
|
||||||
self.next_index += 1;
|
self.next_index += 1;
|
||||||
if self.next_index == self.channels.len() { self.next_index = 0; }
|
if self.next_index == self.channels.len() { self.next_index = 0; }
|
||||||
@ -97,8 +97,8 @@ impl<T> TaskPool<T> {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_task_pool() {
|
fn test_task_pool() {
|
||||||
let f: ~fn() -> ~fn(uint) -> uint = || {
|
let f: proc() -> proc(uint) -> uint = || {
|
||||||
let g: ~fn(uint) -> uint = |i| i;
|
let g: proc(uint) -> uint = |i| i;
|
||||||
g
|
g
|
||||||
};
|
};
|
||||||
let mut pool = TaskPool::new(4, Some(SingleThreaded), f);
|
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,
|
// A function that runs a test. If the function returns successfully,
|
||||||
// the test succeeds; if the function fails then the test fails. We
|
// 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
|
// may need to come up with a more clever definition of test in order
|
||||||
@ -81,10 +86,10 @@ impl TestDesc {
|
|||||||
pub enum TestFn {
|
pub enum TestFn {
|
||||||
StaticTestFn(extern fn()),
|
StaticTestFn(extern fn()),
|
||||||
StaticBenchFn(extern fn(&mut BenchHarness)),
|
StaticBenchFn(extern fn(&mut BenchHarness)),
|
||||||
StaticMetricFn(~fn(&mut MetricMap)),
|
StaticMetricFn(proc(&mut MetricMap)),
|
||||||
DynTestFn(~fn()),
|
DynTestFn(proc()),
|
||||||
DynMetricFn(~fn(&mut MetricMap)),
|
DynMetricFn(proc(&mut MetricMap)),
|
||||||
DynBenchFn(~fn(&mut BenchHarness))
|
DynBenchFn(~TDynBenchFn)
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TestFn {
|
impl TestFn {
|
||||||
@ -859,7 +864,7 @@ pub fn run_test(force_ignore: bool,
|
|||||||
|
|
||||||
fn run_test_inner(desc: TestDesc,
|
fn run_test_inner(desc: TestDesc,
|
||||||
monitor_ch: SharedChan<MonitorMsg>,
|
monitor_ch: SharedChan<MonitorMsg>,
|
||||||
testfn: ~fn()) {
|
testfn: proc()) {
|
||||||
let testfn_cell = ::std::cell::Cell::new(testfn);
|
let testfn_cell = ::std::cell::Cell::new(testfn);
|
||||||
do task::spawn {
|
do task::spawn {
|
||||||
let mut task = task::task();
|
let mut task = task::task();
|
||||||
@ -878,8 +883,8 @@ pub fn run_test(force_ignore: bool,
|
|||||||
}
|
}
|
||||||
|
|
||||||
match testfn {
|
match testfn {
|
||||||
DynBenchFn(benchfn) => {
|
DynBenchFn(bencher) => {
|
||||||
let bs = ::test::bench::benchmark(benchfn);
|
let bs = ::test::bench::benchmark(|harness| bencher.run(harness));
|
||||||
monitor_ch.send((desc, TrBench(bs)));
|
monitor_ch.send((desc, TrBench(bs)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -394,14 +394,14 @@ impl<'self> Prep<'self> {
|
|||||||
pub fn exec<T:Send +
|
pub fn exec<T:Send +
|
||||||
Encodable<json::Encoder> +
|
Encodable<json::Encoder> +
|
||||||
Decodable<json::Decoder>>(
|
Decodable<json::Decoder>>(
|
||||||
&'self self, blk: ~fn(&mut Exec) -> T) -> T {
|
&'self self, blk: proc(&mut Exec) -> T) -> T {
|
||||||
self.exec_work(blk).unwrap()
|
self.exec_work(blk).unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn exec_work<T:Send +
|
fn exec_work<T:Send +
|
||||||
Encodable<json::Encoder> +
|
Encodable<json::Encoder> +
|
||||||
Decodable<json::Decoder>>( // FIXME(#5121)
|
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);
|
let mut bo = Some(blk);
|
||||||
|
|
||||||
debug!("exec_work: looking up {} and {:?}", self.fn_name,
|
debug!("exec_work: looking up {} and {:?}", self.fn_name,
|
||||||
|
Loading…
Reference in New Issue
Block a user