Skip to content

Commit 5db4c62

Browse files
committed
---
yaml --- r: 73293 b: refs/heads/dist-snap c: 7ffd523 h: refs/heads/master i: 73291: 3349f71 v: v3
1 parent cae68cc commit 5db4c62

File tree

3 files changed

+11
-39
lines changed

3 files changed

+11
-39
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
99
refs/heads/incoming: b50030718cf28f2a5a81857a26b57442734fe854
10-
refs/heads/dist-snap: 54eafc009d1595a04862b242fb6825f9e7b51799
10+
refs/heads/dist-snap: 7ffd5233548b841b770b05a915ac6d103334c64f
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1313
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/src/libcore/clone.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ by convention implementing the `Clone` trait and calling the
2525
use core::kinds::Const;
2626

2727
pub trait Clone {
28-
/// Return a deep copy of the owned object tree. Types with shared ownership like managed boxes
29-
/// are cloned with a shallow copy.
28+
/// Returns a copy of the value. The contents of owned pointers
29+
/// are copied to maintain uniqueness, while the contents of
30+
/// managed pointers are not copied.
3031
fn clone(&self) -> Self;
3132
}
3233

@@ -85,8 +86,9 @@ clone_impl!(bool)
8586
clone_impl!(char)
8687

8788
pub trait DeepClone {
88-
/// Return a deep copy of the object tree. Types with shared ownership are also copied via a
89-
/// deep copy, unlike `Clone`.
89+
/// Return a deep copy of the value. Unlike `Clone`, the contents of shared pointer types
90+
/// *are* copied. Note that this is currently unimplemented for managed boxes, as
91+
/// it would need to handle cycles, but it is implemented for other smart-pointer types.
9092
fn deep_clone(&self) -> Self;
9193
}
9294

branches/dist-snap/src/libstd/arc.rs

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012 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
//
@@ -8,33 +8,9 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
/*!
11+
/**
1212
* Concurrency-enabled mechanisms for sharing mutable and/or immutable state
1313
* between tasks.
14-
*
15-
* # Example
16-
*
17-
* In this example, a large vector of floats is shared between several tasks.
18-
* With simple pipes, without ARC, a copy would have to be made for each task.
19-
*
20-
* ~~~
21-
* extern mod std;
22-
* use std::arc;
23-
* let numbers=vec::from_fn(100, |ind| (ind as float)*rand::random());
24-
* let shared_numbers=arc::ARC(numbers);
25-
*
26-
* for 10.times {
27-
* let (port, chan) = stream();
28-
* chan.send(shared_numbers.clone());
29-
*
30-
* do spawn {
31-
* let shared_numbers=port.recv();
32-
* let local_numbers=shared_numbers.get();
33-
*
34-
* // Work with the local numbers
35-
* }
36-
* }
37-
* ~~~
3814
*/
3915

4016
use sync;
@@ -45,7 +21,7 @@ use core::unstable::sync::UnsafeAtomicRcBox;
4521
use core::ptr;
4622
use core::task;
4723

48-
/// As sync::condvar, a mechanism for unlock-and-descheduling and signaling.
24+
/// As sync::condvar, a mechanism for unlock-and-descheduling and signalling.
4925
pub struct Condvar<'self> {
5026
is_mutex: bool,
5127
failed: &'self mut bool,
@@ -117,14 +93,9 @@ pub fn ARC<T:Const + Owned>(data: T) -> ARC<T> {
11793
* wrapper.
11894
*/
11995
pub fn get<'a, T:Const + Owned>(rc: &'a ARC<T>) -> &'a T {
120-
rc.get()
96+
unsafe { &*rc.x.get_immut() }
12197
}
12298

123-
impl<T:Const+Owned> ARC<T> {
124-
pub fn get<'a>(&'a self) -> &'a T {
125-
unsafe { &*self.x.get_immut() }
126-
}
127-
}
12899
/**
129100
* Duplicate an atomically reference counted wrapper.
130101
*
@@ -537,7 +508,6 @@ mod tests {
537508
c.send(arc::clone(&arc_v));
538509

539510
assert_eq!((*arc::get(&arc_v))[2], 3);
540-
assert_eq!(arc_v.get()[4], 5);
541511

542512
info!(arc_v);
543513
}

0 commit comments

Comments
 (0)