Skip to content

Commit 95722ad

Browse files
committed
---
yaml --- r: 10557 b: refs/heads/snap-stage3 c: 0276a33 h: refs/heads/master i: 10555: d463147 v: v3
1 parent dd46682 commit 95722ad

File tree

9 files changed

+17
-75
lines changed

9 files changed

+17
-75
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
refs/heads/master: 2898dcc5d97da9427ac367542382b6239d9c0bbf
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 69447e90021d7a35968ba32a8755a1be7e9d2a4c
4+
refs/heads/snap-stage3: 0276a3376bd18b5acd2a5daaca6167bb1d9bc2d9
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/snap-stage3/src/libcore/core.rc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export float, f32, f64;
3939
export box, char, str, ptr, vec, bool;
4040
export either, option, result, iter;
4141
export libc, os, io, run, rand, sys, unsafe, logging;
42-
export arc, comm, task, future;
42+
export comm, task, future;
4343
export extfmt;
4444
export tuple;
4545
export to_str;
@@ -175,7 +175,6 @@ mod dvec_iter {
175175
}
176176

177177
// Concurrency
178-
mod arc;
179178
mod comm;
180179
mod task;
181180
mod future;

branches/snap-stage3/src/libcore/sys.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export min_align_of;
77
export pref_align_of;
88
export refcount;
99
export log_str;
10-
export create_lock, lock_and_signal, condition, methods;
10+
export lock_and_signal, condition, methods;
1111

1212
enum type_desc = {
1313
first_param: **libc::c_int,
@@ -126,6 +126,8 @@ impl methods for condition {
126126

127127
#[cfg(test)]
128128
mod tests {
129+
use std;
130+
import std::arc;
129131

130132
#[test]
131133
fn size_of_basic() {

branches/snap-stage3/src/libcore/arc.rs renamed to branches/snap-stage3/src/libstd/arc.rs

Lines changed: 2 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,9 @@
22
share immutable data between tasks."]
33

44
import comm::{port, chan, methods};
5-
import sys::methods;
65

76
export arc, get, clone, shared_arc, get_arc;
87

9-
export exclusive, methods;
10-
118
#[abi = "cdecl"]
129
native mod rustrt {
1310
#[rust_stack]
@@ -19,12 +16,12 @@ native mod rustrt {
1916
-> libc::intptr_t;
2017
}
2118

22-
type arc_data<T> = {
19+
type arc_data<T: const> = {
2320
mut count: libc::intptr_t,
2421
data: T
2522
};
2623

27-
resource arc_destruct<T>(data: *libc::c_void) {
24+
resource arc_destruct<T: const>(data: *libc::c_void) {
2825
unsafe {
2926
let data: ~arc_data<T> = unsafe::reinterpret_cast(data);
3027
let new_count = rustrt::rust_atomic_decrement(&mut data.count);
@@ -74,43 +71,6 @@ fn clone<T: const>(rc: &arc<T>) -> arc<T> {
7471
arc_destruct(**rc)
7572
}
7673

77-
// An arc over mutable data that is protected by a lock.
78-
type ex_data<T> = {lock: sys::lock_and_signal, data: T};
79-
type exclusive<T> = arc_destruct<ex_data<T>>;
80-
81-
fn exclusive<T>(-data: T) -> exclusive<T> {
82-
let data = ~{mut count: 1, data: {lock: sys::create_lock(),
83-
data: data}};
84-
unsafe {
85-
let ptr = unsafe::reinterpret_cast(data);
86-
unsafe::forget(data);
87-
arc_destruct(ptr)
88-
}
89-
}
90-
91-
impl methods<T> for exclusive<T> {
92-
fn clone() -> exclusive<T> {
93-
unsafe {
94-
// this makes me nervous...
95-
let ptr: ~arc_data<ex_data<T>> = unsafe::reinterpret_cast(*self);
96-
rustrt::rust_atomic_increment(&mut ptr.count);
97-
unsafe::forget(ptr);
98-
}
99-
arc_destruct(*self)
100-
}
101-
102-
fn with<U>(f: fn(sys::condition, x: &T) -> U) -> U {
103-
unsafe {
104-
let ptr: ~arc_data<ex_data<T>> = unsafe::reinterpret_cast(*self);
105-
let rec: &ex_data<T> = &(*ptr).data;
106-
unsafe::forget(ptr);
107-
rec.lock.lock_cond() {|c|
108-
f(c, &rec.data)
109-
}
110-
}
111-
}
112-
}
113-
11474
// Convenience code for sharing arcs between tasks
11575

11676
type get_chan<T: const send> = chan<chan<arc<T>>>;
@@ -155,7 +115,6 @@ fn get_arc<T: send const>(c: get_chan<T>) -> arc::arc<T> {
155115
#[cfg(test)]
156116
mod tests {
157117
import comm::*;
158-
import future::future;
159118

160119
#[test]
161120
fn manually_share_arc() {
@@ -201,31 +160,4 @@ mod tests {
201160

202161
assert p.recv() == ();
203162
}
204-
205-
#[test]
206-
fn exclusive_arc() {
207-
let mut futures = [];
208-
209-
let num_tasks = 10u;
210-
let count = 1000u;
211-
212-
let total = exclusive(~mut 0u);
213-
214-
for uint::range(0u, num_tasks) {|_i|
215-
let total = total.clone();
216-
futures += [future::spawn({||
217-
for uint::range(0u, count) {|_i|
218-
total.with {|_cond, count|
219-
**count += 1u;
220-
}
221-
}
222-
})];
223-
};
224-
225-
for futures.each {|f| f.get() };
226-
227-
total.with {|_cond, total|
228-
assert **total == num_tasks * count
229-
};
230-
}
231163
}

branches/snap-stage3/src/libstd/std.rc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export net, net_tcp;
1919
export uv, uv_ll, uv_iotask, uv_global_loop;
2020
export c_vec, util, timer;
2121
export bitv, deque, fun_treemap, list, map, smallintmap, sort, treemap;
22-
export rope, arena, par;
22+
export rope, arena, arc, par;
2323
export ebml, dbg, getopts, json, rand, sha1, term, time, prettyprint;
2424
export test, tempfile, serialization;
2525
export cmp;
@@ -69,6 +69,7 @@ mod term;
6969
mod time;
7070
mod prettyprint;
7171
mod arena;
72+
mod arc;
7273
mod par;
7374
mod cmp;
7475

branches/snap-stage3/src/test/bench/graph500-bfs.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import std::map;
1010
import std::map::hashmap;
1111
import std::deque;
1212
import std::deque::t;
13+
import std::arc;
1314
import std::par;
1415
import io::writer_util;
1516
import comm::*;

branches/snap-stage3/src/test/compile-fail/no-capture-arc.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// error-pattern: copying a noncopyable value
22

3+
use std;
4+
import std::arc;
35
import comm::*;
46

57
fn main() {

branches/snap-stage3/src/test/compile-fail/no-reuse-move-arc.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std;
2+
import std::arc;
13
import comm::*;
24

35
fn main() {

branches/snap-stage3/src/test/run-fail/issue-2444.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
// error-pattern:explicit failure
22

3+
use std;
4+
import std::arc;
5+
36
enum e<T: const> { e(arc::arc<T>) }
47

58
fn foo() -> e<int> {fail;}

0 commit comments

Comments
 (0)