Skip to content

Commit f4c22f7

Browse files
committed
auto merge of #10561 : pcwalton/rust/procify, r=alexcrichton
r? @alexcrichton
2 parents f5f5d5a + f977bed commit f4c22f7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+186
-265
lines changed

doc/po/ja/tutorial-tasks.md.po

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ msgstr ""
213213
#. type: Plain text
214214
#: doc/tutorial-tasks.md:102
215215
msgid ""
216-
"The `spawn` function has a very simple type signature: `fn spawn(f: ~fn())`. "
216+
"The `spawn` function has a very simple type signature: `fn spawn(f: proc())`. "
217217
"Because it accepts only owned closures, and owned closures contain only "
218218
"owned data, `spawn` can safely move the entire closure and all its "
219219
"associated state into an entirely different task for execution. Like any "

doc/po/ja/tutorial.md.po

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3509,13 +3509,13 @@ msgstr "## 所有クロージャ"
35093509
#. type: Plain text
35103510
#: doc/tutorial.md:1510
35113511
msgid ""
3512-
"Owned closures, written `~fn` in analogy to the `~` pointer type, hold on to "
3512+
"Owned closures, written `proc`, hold on to "
35133513
"things that can safely be sent between processes. They copy the values they "
35143514
"close over, much like managed closures, but they also own them: that is, no "
35153515
"other code can access them. Owned closures are used in concurrent code, "
35163516
"particularly for spawning [tasks][tasks]."
35173517
msgstr ""
3518-
"`~` ポインタ型と同様に `~fn` 型 で書き表される所有クロージャは安全にプロセス"
3518+
"`~` `proc` で書き表される所有クロージャは安全にプロセス"
35193519
"間で送信することができます。所有クローじゃはマネージドクロージャと全く同じよ"
35203520
"うに閉じ込める値をコピーしますが、値を所有します。つまり、他のコードは閉じ込"
35213521
"められた値にアクセスできなくなります。所有クロージャは並列プログラム、特に "
@@ -3666,11 +3666,11 @@ msgstr ""
36663666
#: doc/tutorial.md:1582
36673667
msgid ""
36683668
"`do` is a convenient way to create tasks with the `task::spawn` function. "
3669-
"`spawn` has the signature `spawn(fn: ~fn())`. In other words, it is a "
3669+
"`spawn` has the signature `spawn(fn: proc())`. In other words, it is a "
36703670
"function that takes an owned closure that takes no arguments."
36713671
msgstr ""
36723672
"`task::spawn` 関数を用いてタスクを生成する場合、 `do` を用いると便利です。"
3673-
"`spawn` は、 `spawn(fn: ~fn())` という方を持っています。言い換えると、"
3673+
"`spawn` は、 `spawn(fn: proc())` という方を持っています。言い換えると、"
36743674
"`spawn` は「引数をとらない所有クロージャ」を引数としてとる関数ということで"
36753675
"す。"
36763676

doc/po/tutorial-tasks.md.pot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ msgstr ""
213213
#. type: Plain text
214214
#: doc/tutorial-tasks.md:102
215215
msgid ""
216-
"The `spawn` function has a very simple type signature: `fn spawn(f: ~fn())`. "
216+
"The `spawn` function has a very simple type signature: `fn spawn(f: proc())`. "
217217
"Because it accepts only owned closures, and owned closures contain only "
218218
"owned data, `spawn` can safely move the entire closure and all its "
219219
"associated state into an entirely different task for execution. Like any "

doc/po/tutorial.md.pot

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2683,7 +2683,7 @@ msgstr ""
26832683
#. type: Plain text
26842684
#: doc/tutorial.md:1510
26852685
msgid ""
2686-
"Owned closures, written `~fn` in analogy to the `~` pointer type, hold on to "
2686+
"Owned closures, written `proc`, hold on to "
26872687
"things that can safely be sent between processes. They copy the values they "
26882688
"close over, much like managed closures, but they also own them: that is, no "
26892689
"other code can access them. Owned closures are used in concurrent code, "
@@ -2808,7 +2808,7 @@ msgstr ""
28082808
#: doc/tutorial.md:1582
28092809
msgid ""
28102810
"`do` is a convenient way to create tasks with the `task::spawn` function. "
2811-
"`spawn` has the signature `spawn(fn: ~fn())`. In other words, it is a "
2811+
"`spawn` has the signature `spawn(fn: proc())`. In other words, it is a "
28122812
"function that takes an owned closure that takes no arguments."
28132813
msgstr ""
28142814

doc/tutorial-tasks.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ _owned types_. The language leaves the implementation details to the standard
9191
library.
9292

9393
The `spawn` function has a very simple type signature: `fn spawn(f:
94-
~fn())`. Because it accepts only owned closures, and owned closures
94+
proc())`. Because it accepts only owned closures, and owned closures
9595
contain only owned data, `spawn` can safely move the entire closure
9696
and all its associated state into an entirely different task for
9797
execution. Like any closure, the function passed to `spawn` may capture

doc/tutorial.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1409,7 +1409,7 @@ pervasively in Rust code.
14091409
14101410
## Owned closures
14111411
1412-
Owned closures, written `~fn` in analogy to the `~` pointer type,
1412+
Owned closures, written `proc`,
14131413
hold on to things that can safely be sent between
14141414
processes. They copy the values they close over, much like managed
14151415
closures, but they also own them: that is, no other code can access
@@ -1484,7 +1484,7 @@ parentheses, where it looks more like a typical block of
14841484
code.
14851485
14861486
`do` is a convenient way to create tasks with the `task::spawn`
1487-
function. `spawn` has the signature `spawn(fn: ~fn())`. In other
1487+
function. `spawn` has the signature `spawn(fn: proc())`. In other
14881488
words, it is a function that takes an owned closure that takes no
14891489
arguments.
14901490

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: &fn() -> 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)