Skip to content

Commit 5633a53

Browse files
committed
auto merge of #8008 : bblum/rust/select, r=brson
Main logic in ```Implement select() for new runtime pipes.```. The guts of the ```PortOne::try_recv()``` implementation are now split up across several functions, ```optimistic_check```, ```block_on```, and ```recv_ready```. There is one weird FIXME I left open here, in the "implement select" commit -- an assertion I couldn't get to work in the receive path, on an invariant that for some reason doesn't hold with ```SharedPort```. Still investigating this.
2 parents 6534b4d + 6b75e92 commit 5633a53

File tree

9 files changed

+792
-283
lines changed

9 files changed

+792
-283
lines changed

src/libextra/arc.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ impl<T:Freeze+Send> Arc<T> {
136136
*/
137137
pub fn unwrap(self) -> T {
138138
let Arc { x: x } = self;
139-
unsafe { x.unwrap() }
139+
x.unwrap()
140140
}
141141
}
142142

@@ -250,7 +250,7 @@ impl<T:Send> MutexArc<T> {
250250
*/
251251
pub fn unwrap(self) -> T {
252252
let MutexArc { x: x } = self;
253-
let inner = unsafe { x.unwrap() };
253+
let inner = x.unwrap();
254254
let MutexArcInner { failed: failed, data: data, _ } = inner;
255255
if failed {
256256
fail!(~"Can't unwrap poisoned MutexArc - another task failed inside!");
@@ -469,7 +469,7 @@ impl<T:Freeze + Send> RWArc<T> {
469469
*/
470470
pub fn unwrap(self) -> T {
471471
let RWArc { x: x, _ } = self;
472-
let inner = unsafe { x.unwrap() };
472+
let inner = x.unwrap();
473473
let RWArcInner { failed: failed, data: data, _ } = inner;
474474
if failed {
475475
fail!(~"Can't unwrap poisoned RWArc - another task failed inside!")

src/libextra/sync.rs

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,9 @@ impl<Q:Send> Sem<Q> {
130130
impl Sem<()> {
131131
pub fn access<U>(&self, blk: &fn() -> U) -> U {
132132
let mut release = None;
133-
unsafe {
134-
do task::unkillable {
135-
self.acquire();
136-
release = Some(SemRelease(self));
137-
}
133+
do task::unkillable {
134+
self.acquire();
135+
release = Some(SemRelease(self));
138136
}
139137
blk()
140138
}
@@ -153,11 +151,9 @@ impl Sem<~[WaitQueue]> {
153151

154152
pub fn access_waitqueue<U>(&self, blk: &fn() -> U) -> U {
155153
let mut release = None;
156-
unsafe {
157-
do task::unkillable {
158-
self.acquire();
159-
release = Some(SemAndSignalRelease(self));
160-
}
154+
do task::unkillable {
155+
self.acquire();
156+
release = Some(SemAndSignalRelease(self));
161157
}
162158
blk()
163159
}
@@ -294,17 +290,15 @@ impl<'self> Condvar<'self> {
294290
#[unsafe_destructor]
295291
impl<'self> Drop for CondvarReacquire<'self> {
296292
fn drop(&self) {
297-
unsafe {
298-
// Needs to succeed, instead of itself dying.
299-
do task::unkillable {
300-
match self.order {
301-
Just(lock) => do lock.access {
302-
self.sem.acquire();
303-
},
304-
Nothing => {
305-
self.sem.acquire();
306-
},
307-
}
293+
// Needs to succeed, instead of itself dying.
294+
do task::unkillable {
295+
match self.order {
296+
Just(lock) => do lock.access {
297+
self.sem.acquire();
298+
},
299+
Nothing => {
300+
self.sem.acquire();
301+
},
308302
}
309303
}
310304
}
@@ -644,14 +638,12 @@ impl RWLock {
644638
// Implementation slightly different from the slicker 'write's above.
645639
// The exit path is conditional on whether the caller downgrades.
646640
let mut _release = None;
647-
unsafe {
648-
do task::unkillable {
649-
(&self.order_lock).acquire();
650-
(&self.access_lock).acquire();
651-
(&self.order_lock).release();
652-
}
653-
_release = Some(RWLockReleaseDowngrade(self));
641+
do task::unkillable {
642+
(&self.order_lock).acquire();
643+
(&self.access_lock).acquire();
644+
(&self.order_lock).release();
654645
}
646+
_release = Some(RWLockReleaseDowngrade(self));
655647
blk(RWLockWriteMode { lock: self })
656648
}
657649

0 commit comments

Comments
 (0)