Skip to content

Commit 78790b0

Browse files
author
Olivier Saut
committed
---
yaml --- r: 65270 b: refs/heads/master c: f212543 h: refs/heads/master v: v3
1 parent 3a1241a commit 78790b0

File tree

6 files changed

+33
-44
lines changed

6 files changed

+33
-44
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 264c84b892f531f968b1ab9c9b8e15f2c66cf524
2+
refs/heads/master: f2125434d86669d3086094397855f80c2bf636ac
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 18e3db7392d2d0697b7e27d6d986139960144d85
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9

trunk/src/libextra/arc.rs

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ pub impl<'self> Condvar<'self> {
107107
****************************************************************************/
108108

109109
/// An atomically reference counted wrapper for shared immutable state.
110-
struct ARC<T> { x: UnsafeAtomicRcBox<T> }
110+
pub struct ARC<T> { x: UnsafeAtomicRcBox<T> }
111111

112112
/// Create an atomically reference counted wrapper.
113113
pub fn ARC<T:Const + Owned>(data: T) -> ARC<T> {
@@ -118,12 +118,8 @@ pub fn ARC<T:Const + Owned>(data: T) -> ARC<T> {
118118
* Access the underlying data in an atomically reference counted
119119
* wrapper.
120120
*/
121-
pub fn get<'a, T:Const + Owned>(rc: &'a ARC<T>) -> &'a T {
122-
rc.get()
123-
}
124-
125-
impl<T:Const+Owned> ARC<T> {
126-
pub fn get<'a>(&'a self) -> &'a T {
121+
pub impl<T:Const+Owned> ARC<T> {
122+
fn get<'a>(&'a self) -> &'a T {
127123
unsafe { &*self.x.get_immut() }
128124
}
129125
}
@@ -512,34 +508,31 @@ pub impl<'self, T:Const + Owned> RWReadMode<'self, T> {
512508
#[cfg(test)]
513509
mod tests {
514510
use core::prelude::*;
515-
511+
use core::cell::Cell;
516512
use arc::*;
517513
use arc;
518514

519-
use core::cell::Cell;
520-
use core::task;
521-
522515
#[test]
523516
fn manually_share_arc() {
524517
let v = ~[1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
525-
let arc_v = arc::ARC(v);
518+
let arc_v = ARC(v);
526519

527520
let (p, c) = comm::stream();
528521

529522
do task::spawn() || {
530523
let p = comm::PortSet::new();
531524
c.send(p.chan());
532525

533-
let arc_v = p.recv();
526+
let arc_v : ARC<~[int]> = p.recv();
534527

535-
let v = copy *arc::get::<~[int]>(&arc_v);
528+
let v = copy (*arc_v.get());
536529
assert_eq!(v[3], 4);
537530
};
538531

539532
let c = p.recv();
540-
c.send(arc::clone(&arc_v));
533+
c.send(arc_v.clone());
541534

542-
assert_eq!((*arc::get(&arc_v))[2], 3);
535+
assert_eq!(arc_v.get()[2], 3);
543536
assert_eq!(arc_v.get()[4], 5);
544537

545538
info!(arc_v);

trunk/src/librust/rust.rc

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,16 @@ extern mod rustc;
3232
use core::prelude::*;
3333

3434
use core::run;
35-
use core::libc::exit;
3635

3736
enum ValidUsage {
38-
Valid(int), Invalid
37+
Valid, Invalid
3938
}
4039

4140
impl ValidUsage {
4241
fn is_valid(&self) -> bool {
4342
match *self {
44-
Valid(_) => true,
45-
Invalid => false
43+
Valid => true,
44+
Invalid => false
4645
}
4746
}
4847
}
@@ -145,7 +144,7 @@ fn cmd_help(args: &[~str]) -> ValidUsage {
145144
UsgStr(msg) => io::println(fmt!("%s\n", msg)),
146145
UsgCall(f) => f(),
147146
}
148-
Valid(0)
147+
Valid
149148
},
150149
None => Invalid
151150
}
@@ -163,8 +162,8 @@ fn cmd_test(args: &[~str]) -> ValidUsage {
163162
let test_exec = Path(filename).filestem().unwrap() + "test~";
164163
invoke("rustc", &[~"--test", filename.to_owned(),
165164
~"-o", test_exec.to_owned()], rustc::main);
166-
let exit_code = run::run_program(~"./" + test_exec, []);
167-
Valid(exit_code)
165+
run::run_program(~"./" + test_exec, []);
166+
Valid
168167
}
169168
_ => Invalid
170169
}
@@ -176,8 +175,8 @@ fn cmd_run(args: &[~str]) -> ValidUsage {
176175
let exec = Path(filename).filestem().unwrap() + "~";
177176
invoke("rustc", &[filename.to_owned(), ~"-o", exec.to_owned()],
178177
rustc::main);
179-
let exit_code = run::run_program(~"./"+exec, prog_args);
180-
Valid(exit_code)
178+
run::run_program(~"./"+exec, prog_args);
179+
Valid
181180
}
182181
_ => Invalid
183182
}
@@ -195,7 +194,7 @@ fn do_command(command: &Command, args: &[~str]) -> ValidUsage {
195194
Call(f) => f(args),
196195
CallMain(prog, f) => {
197196
invoke(prog, args, f);
198-
Valid(0)
197+
Valid
199198
}
200199
}
201200
}
@@ -234,10 +233,7 @@ pub fn main() {
234233
if !args.is_empty() {
235234
for find_cmd(*args.head()).each |command| {
236235
let result = do_command(command, args.tail());
237-
match result {
238-
Valid(exit_code) => unsafe { exit(exit_code.to_i32()) },
239-
_ => loop
240-
}
236+
if result.is_valid() { return; }
241237
}
242238
}
243239

trunk/src/test/bench/graph500-bfs.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// xfail-pretty
22

3-
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
3+
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
44
// file at the top-level directory of this distribution and at
55
// http://rust-lang.org/COPYRIGHT.
66
//
@@ -234,7 +234,7 @@ fn pbfs(graph: &arc::ARC<graph>, key: node_id) -> bfs_result {
234234
black(node_id)
235235
};
236236

237-
let graph_vec = arc::get(graph); // FIXME #3387 requires this temp
237+
let graph_vec = graph.get(); // FIXME #3387 requires this temp
238238
let mut colors = do vec::from_fn(graph_vec.len()) |i| {
239239
if i as node_id == key {
240240
gray(key)
@@ -266,13 +266,13 @@ fn pbfs(graph: &arc::ARC<graph>, key: node_id) -> bfs_result {
266266

267267
let color = arc::ARC(colors);
268268

269-
let color_vec = arc::get(&color); // FIXME #3387 requires this temp
269+
let color_vec = color.get(); // FIXME #3387 requires this temp
270270
colors = do par::mapi(*color_vec) {
271-
let colors = arc::clone(&color);
272-
let graph = arc::clone(graph);
271+
let colors = color.clone();
272+
let graph = graph.clone();
273273
let result: ~fn(x: uint, y: &color) -> color = |i, c| {
274-
let colors = arc::get(&colors);
275-
let graph = arc::get(&graph);
274+
let colors = colors.get();
275+
let graph = graph.get();
276276
match *c {
277277
white => {
278278
let i = i as node_id;

trunk/src/test/compile-fail/no-capture-arc.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -18,11 +18,11 @@ fn main() {
1818
let arc_v = arc::ARC(v);
1919

2020
do task::spawn() {
21-
let v = *arc::get(&arc_v);
21+
let v = arc_v.get();
2222
assert_eq!(v[3], 4);
2323
};
2424

25-
assert_eq!((*arc::get(&arc_v))[2], 3);
25+
assert_eq!((arc_v.get())[2], 3);
2626

2727
info!(arc_v);
2828
}

trunk/src/test/compile-fail/no-reuse-move-arc.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -16,11 +16,11 @@ fn main() {
1616
let arc_v = arc::ARC(v);
1717

1818
do task::spawn() { //~ NOTE `arc_v` moved into closure environment here
19-
let v = *arc::get(&arc_v);
19+
let v = arc_v.get();
2020
assert_eq!(v[3], 4);
2121
};
2222

23-
assert!((*arc::get(&arc_v))[2] == 3); //~ ERROR use of moved value: `arc_v`
23+
assert_eq!((arc_v.get())[2], 3); //~ ERROR use of moved value: `arc_v`
2424

2525
info!(arc_v);
2626
}

0 commit comments

Comments
 (0)