Skip to content

Commit 77b9b9f

Browse files
committed
---
yaml --- r: 151899 b: refs/heads/try2 c: 05a453e h: refs/heads/master i: 151897: a46e61a 151895: bad4195 v: v3
1 parent 5490dee commit 77b9b9f

File tree

3 files changed

+19
-18
lines changed

3 files changed

+19
-18
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 5e10d373b597192f101b52060c95adaa83c48663
8+
refs/heads/try2: 05a453edb3f97aab4c15efdeae238aaea21849a5
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libgreen/lib.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,9 @@
214214
#[cfg(test)] extern crate rustuv;
215215
extern crate rand;
216216
extern crate libc;
217+
extern crate alloc;
217218

219+
use alloc::arc::Arc;
218220
use std::mem::replace;
219221
use std::os;
220222
use std::rt::rtio;
@@ -223,7 +225,6 @@ use std::rt;
223225
use std::sync::atomics::{SeqCst, AtomicUint, INIT_ATOMIC_UINT};
224226
use std::sync::deque;
225227
use std::task::TaskOpts;
226-
use std::sync::arc::UnsafeArc;
227228

228229
use sched::{Shutdown, Scheduler, SchedHandle, TaskFromFriend, NewNeighbor};
229230
use sleeper_list::SleeperList;
@@ -375,7 +376,7 @@ pub struct SchedPool {
375376
/// sending on a channel once the entire pool has been drained of all tasks.
376377
#[deriving(Clone)]
377378
struct TaskState {
378-
cnt: UnsafeArc<AtomicUint>,
379+
cnt: Arc<AtomicUint>,
379380
done: Sender<()>,
380381
}
381382

@@ -537,21 +538,21 @@ impl TaskState {
537538
fn new() -> (Receiver<()>, TaskState) {
538539
let (tx, rx) = channel();
539540
(rx, TaskState {
540-
cnt: UnsafeArc::new(AtomicUint::new(0)),
541+
cnt: Arc::new(AtomicUint::new(0)),
541542
done: tx,
542543
})
543544
}
544545

545546
fn increment(&mut self) {
546-
unsafe { (*self.cnt.get()).fetch_add(1, SeqCst); }
547+
self.cnt.fetch_add(1, SeqCst);
547548
}
548549

549550
fn active(&self) -> bool {
550-
unsafe { (*self.cnt.get()).load(SeqCst) != 0 }
551+
self.cnt.load(SeqCst) != 0
551552
}
552553

553554
fn decrement(&mut self) {
554-
let prev = unsafe { (*self.cnt.get()).fetch_sub(1, SeqCst) };
555+
let prev = self.cnt.fetch_sub(1, SeqCst);
555556
if prev == 1 {
556557
self.done.send(());
557558
}

branches/try2/src/libgreen/message_queue.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
use alloc::arc::Arc;
1112
use mpsc = std::sync::mpsc_queue;
12-
use std::sync::arc::UnsafeArc;
1313

1414
pub enum PopResult<T> {
1515
Inconsistent,
@@ -18,29 +18,29 @@ pub enum PopResult<T> {
1818
}
1919

2020
pub fn queue<T: Send>() -> (Consumer<T>, Producer<T>) {
21-
let (a, b) = UnsafeArc::new2(mpsc::Queue::new());
22-
(Consumer { inner: a }, Producer { inner: b })
21+
let a = Arc::new(mpsc::Queue::new());
22+
(Consumer { inner: a.clone() }, Producer { inner: a })
2323
}
2424

2525
pub struct Producer<T> {
26-
inner: UnsafeArc<mpsc::Queue<T>>,
26+
inner: Arc<mpsc::Queue<T>>,
2727
}
2828

2929
pub struct Consumer<T> {
30-
inner: UnsafeArc<mpsc::Queue<T>>,
30+
inner: Arc<mpsc::Queue<T>>,
3131
}
3232

3333
impl<T: Send> Consumer<T> {
34-
pub fn pop(&mut self) -> PopResult<T> {
35-
match unsafe { (*self.inner.get()).pop() } {
34+
pub fn pop(&self) -> PopResult<T> {
35+
match self.inner.pop() {
3636
mpsc::Inconsistent => Inconsistent,
3737
mpsc::Empty => Empty,
3838
mpsc::Data(t) => Data(t),
3939
}
4040
}
4141

42-
pub fn casual_pop(&mut self) -> Option<T> {
43-
match unsafe { (*self.inner.get()).pop() } {
42+
pub fn casual_pop(&self) -> Option<T> {
43+
match self.inner.pop() {
4444
mpsc::Inconsistent => None,
4545
mpsc::Empty => None,
4646
mpsc::Data(t) => Some(t),
@@ -49,8 +49,8 @@ impl<T: Send> Consumer<T> {
4949
}
5050

5151
impl<T: Send> Producer<T> {
52-
pub fn push(&mut self, t: T) {
53-
unsafe { (*self.inner.get()).push(t); }
52+
pub fn push(&self, t: T) {
53+
self.inner.push(t);
5454
}
5555
}
5656

0 commit comments

Comments
 (0)