Skip to content

Commit 4c8a4d2

Browse files
committed
std: Remove UnsafeArc
This type has been superseded by Arc<Unsafe<T>>. The UnsafeArc type is a relic of an era that has long since past, and with the introduction of liballoc the standard library is able to use the Arc smart pointer. With little need left for UnsafeArc, it was removed. All existing code using UnsafeArc should either be reevaluated to whether it can use only Arc, or it should transition to Arc<Unsafe<T>> [breaking-change]
1 parent 73729e9 commit 4c8a4d2

File tree

6 files changed

+23
-218
lines changed

6 files changed

+23
-218
lines changed

src/libstd/sync/arc.rs

Lines changed: 0 additions & 189 deletions
This file was deleted.

src/libstd/sync/deque.rs

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -417,8 +417,8 @@ mod tests {
417417

418418
#[test]
419419
fn smoke() {
420-
let mut pool = BufferPool::new();
421-
let (mut w, mut s) = pool.deque();
420+
let pool = BufferPool::new();
421+
let (w, s) = pool.deque();
422422
assert_eq!(w.pop(), None);
423423
assert_eq!(s.steal(), Empty);
424424
w.push(1);
@@ -432,10 +432,9 @@ mod tests {
432432
#[test]
433433
fn stealpush() {
434434
static AMT: int = 100000;
435-
let mut pool = BufferPool::<int>::new();
436-
let (mut w, s) = pool.deque();
435+
let pool = BufferPool::<int>::new();
436+
let (w, s) = pool.deque();
437437
let t = Thread::start(proc() {
438-
let mut s = s;
439438
let mut left = AMT;
440439
while left > 0 {
441440
match s.steal() {
@@ -458,10 +457,9 @@ mod tests {
458457
#[test]
459458
fn stealpush_large() {
460459
static AMT: int = 100000;
461-
let mut pool = BufferPool::<(int, int)>::new();
462-
let (mut w, s) = pool.deque();
460+
let pool = BufferPool::<(int, int)>::new();
461+
let (w, s) = pool.deque();
463462
let t = Thread::start(proc() {
464-
let mut s = s;
465463
let mut left = AMT;
466464
while left > 0 {
467465
match s.steal() {
@@ -479,7 +477,7 @@ mod tests {
479477
t.join();
480478
}
481479

482-
fn stampede(mut w: Worker<Box<int>>, s: Stealer<Box<int>>,
480+
fn stampede(w: Worker<Box<int>>, s: Stealer<Box<int>>,
483481
nthreads: int, amt: uint) {
484482
for _ in range(0, amt) {
485483
w.push(box 20);
@@ -491,7 +489,6 @@ mod tests {
491489
let s = s.clone();
492490
Thread::start(proc() {
493491
unsafe {
494-
let mut s = s;
495492
while (*unsafe_remaining).load(SeqCst) > 0 {
496493
match s.steal() {
497494
Data(box 20) => {
@@ -520,15 +517,15 @@ mod tests {
520517

521518
#[test]
522519
fn run_stampede() {
523-
let mut pool = BufferPool::<Box<int>>::new();
520+
let pool = BufferPool::<Box<int>>::new();
524521
let (w, s) = pool.deque();
525522
stampede(w, s, 8, 10000);
526523
}
527524

528525
#[test]
529526
fn many_stampede() {
530527
static AMT: uint = 4;
531-
let mut pool = BufferPool::<Box<int>>::new();
528+
let pool = BufferPool::<Box<int>>::new();
532529
let threads = range(0, AMT).map(|_| {
533530
let (w, s) = pool.deque();
534531
Thread::start(proc() {
@@ -547,14 +544,13 @@ mod tests {
547544
static NTHREADS: int = 8;
548545
static mut DONE: AtomicBool = INIT_ATOMIC_BOOL;
549546
static mut HITS: AtomicUint = INIT_ATOMIC_UINT;
550-
let mut pool = BufferPool::<int>::new();
551-
let (mut w, s) = pool.deque();
547+
let pool = BufferPool::<int>::new();
548+
let (w, s) = pool.deque();
552549

553550
let threads = range(0, NTHREADS).map(|_| {
554551
let s = s.clone();
555552
Thread::start(proc() {
556553
unsafe {
557-
let mut s = s;
558554
loop {
559555
match s.steal() {
560556
Data(2) => { HITS.fetch_add(1, SeqCst); }
@@ -606,8 +602,8 @@ mod tests {
606602
static AMT: int = 10000;
607603
static NTHREADS: int = 4;
608604
static mut DONE: AtomicBool = INIT_ATOMIC_BOOL;
609-
let mut pool = BufferPool::<(int, uint)>::new();
610-
let (mut w, s) = pool.deque();
605+
let pool = BufferPool::<(int, uint)>::new();
606+
let (w, s) = pool.deque();
611607

612608
let (threads, hits) = vec::unzip(range(0, NTHREADS).map(|_| {
613609
let s = s.clone();
@@ -617,7 +613,6 @@ mod tests {
617613
};
618614
(Thread::start(proc() {
619615
unsafe {
620-
let mut s = s;
621616
loop {
622617
match s.steal() {
623618
Data((1, 2)) => {

src/libstd/sync/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
//! and/or blocking at all, but rather provide the necessary tools to build
1616
//! other types of concurrent primitives.
1717
18-
pub mod arc;
1918
pub mod atomics;
2019
pub mod deque;
2120
pub mod mpmc_bounded_queue;

src/libstd/sync/mpmc_bounded_queue.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,15 +173,15 @@ mod tests {
173173
fn test() {
174174
let nthreads = 8u;
175175
let nmsgs = 1000u;
176-
let mut q = Queue::with_capacity(nthreads*nmsgs);
176+
let q = Queue::with_capacity(nthreads*nmsgs);
177177
assert_eq!(None, q.pop());
178178
let (tx, rx) = channel();
179179

180180
for _ in range(0, nthreads) {
181181
let q = q.clone();
182182
let tx = tx.clone();
183183
native::task::spawn(proc() {
184-
let mut q = q;
184+
let q = q;
185185
for i in range(0, nmsgs) {
186186
assert!(q.push(i));
187187
}
@@ -195,7 +195,7 @@ mod tests {
195195
completion_rxs.push(rx);
196196
let q = q.clone();
197197
native::task::spawn(proc() {
198-
let mut q = q;
198+
let q = q;
199199
let mut i = 0u;
200200
loop {
201201
match q.pop() {

src/libstd/sync/mpsc_queue.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ mod tests {
165165

166166
#[test]
167167
fn test_full() {
168-
let mut q = Queue::new();
168+
let q = Queue::new();
169169
q.push(box 1);
170170
q.push(box 2);
171171
}
@@ -174,7 +174,7 @@ mod tests {
174174
fn test() {
175175
let nthreads = 8u;
176176
let nmsgs = 1000u;
177-
let mut q = Queue::new();
177+
let q = Queue::new();
178178
match q.pop() {
179179
Empty => {}
180180
Inconsistent | Data(..) => fail!()

src/libstd/sync/spsc_queue.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ mod test {
235235

236236
#[test]
237237
fn smoke() {
238-
let mut q = Queue::new(0);
238+
let q = Queue::new(0);
239239
q.push(1);
240240
q.push(2);
241241
assert_eq!(q.pop(), Some(1));
@@ -250,14 +250,14 @@ mod test {
250250

251251
#[test]
252252
fn drop_full() {
253-
let mut q = Queue::new(0);
253+
let q = Queue::new(0);
254254
q.push(box 1);
255255
q.push(box 2);
256256
}
257257

258258
#[test]
259259
fn smoke_bound() {
260-
let mut q = Queue::new(1);
260+
let q = Queue::new(1);
261261
q.push(1);
262262
q.push(2);
263263
assert_eq!(q.pop(), Some(1));
@@ -282,7 +282,7 @@ mod test {
282282
native::task::spawn(proc() {
283283
for _ in range(0, 100000) {
284284
loop {
285-
match unsafe { (*b.get()).pop() } {
285+
match b.pop() {
286286
Some(1) => break,
287287
Some(_) => fail!(),
288288
None => {}
@@ -292,7 +292,7 @@ mod test {
292292
tx.send(());
293293
});
294294
for _ in range(0, 100000) {
295-
unsafe { (*a.get()).push(1); }
295+
a.push(1);
296296
}
297297
rx.recv();
298298
}

0 commit comments

Comments
 (0)