13
13
//! local storage, and logging. Even a 'freestanding' Rust would likely want
14
14
//! to implement this.
15
15
16
+ use alloc:: arc:: Arc ;
17
+
16
18
use cleanup;
17
19
use clone:: Clone ;
18
20
use comm:: Sender ;
@@ -32,7 +34,6 @@ use rt::local_heap::LocalHeap;
32
34
use rt:: rtio:: LocalIo ;
33
35
use rt:: unwind:: Unwinder ;
34
36
use str:: SendStr ;
35
- use sync:: arc:: UnsafeArc ;
36
37
use sync:: atomics:: { AtomicUint , SeqCst } ;
37
38
use task:: { TaskResult , TaskOpts } ;
38
39
use unstable:: finally:: Finally ;
@@ -65,7 +66,7 @@ pub struct LocalStorage(pub Option<local_data::Map>);
65
66
/// at any time.
66
67
pub enum BlockedTask {
67
68
Owned ( Box < Task > ) ,
68
- Shared ( UnsafeArc < AtomicUint > ) ,
69
+ Shared ( Arc < AtomicUint > ) ,
69
70
}
70
71
71
72
pub enum DeathAction {
@@ -82,7 +83,7 @@ pub struct Death {
82
83
}
83
84
84
85
pub struct BlockedTasks {
85
- inner : UnsafeArc < AtomicUint > ,
86
+ inner : Arc < AtomicUint > ,
86
87
}
87
88
88
89
impl Task {
@@ -313,10 +314,10 @@ impl BlockedTask {
313
314
pub fn wake ( self ) -> Option < Box < Task > > {
314
315
match self {
315
316
Owned ( task) => Some ( task) ,
316
- Shared ( arc) => unsafe {
317
- match ( * arc. get ( ) ) . swap ( 0 , SeqCst ) {
317
+ Shared ( arc) => {
318
+ match arc. swap ( 0 , SeqCst ) {
318
319
0 => None ,
319
- n => Some ( mem:: transmute ( n) ) ,
320
+ n => Some ( unsafe { mem:: transmute ( n) } ) ,
320
321
}
321
322
}
322
323
}
@@ -343,7 +344,7 @@ impl BlockedTask {
343
344
let arc = match self {
344
345
Owned ( task) => {
345
346
let flag = unsafe { AtomicUint :: new ( mem:: transmute ( task) ) } ;
346
- UnsafeArc :: new ( flag)
347
+ Arc :: new ( flag)
347
348
}
348
349
Shared ( arc) => arc. clone ( ) ,
349
350
} ;
@@ -375,7 +376,7 @@ impl BlockedTask {
375
376
if blocked_task_ptr & 0x1 == 0 {
376
377
Owned ( mem:: transmute ( blocked_task_ptr) )
377
378
} else {
378
- let ptr: Box < UnsafeArc < AtomicUint > > =
379
+ let ptr: Box < Arc < AtomicUint > > =
379
380
mem:: transmute ( blocked_task_ptr & !1 ) ;
380
381
Shared ( * ptr)
381
382
}
0 commit comments