diff options
| author | bors <bors@rust-lang.org> | 2013-08-08 14:32:02 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-08-08 14:32:02 -0700 |
| commit | 8f65dbfcfa11aa521aa59881f6ab064bbd07184e (patch) | |
| tree | 8d482dd18bcf6651529fa26941b7a1598cd3dfc2 /src/libstd/rt | |
| parent | a0080f4e07891c89aa1f9851f8b0a3c754734fe8 (diff) | |
| parent | 878e74e1cedd80a909e06073f8fb677d6ffd895f (diff) | |
| download | rust-8f65dbfcfa11aa521aa59881f6ab064bbd07184e.tar.gz rust-8f65dbfcfa11aa521aa59881f6ab064bbd07184e.zip | |
auto merge of #8385 : cmr/rust/big-rollup, r=alexcrichton
This is a fairly large rollup, but I've tested everything locally, and none of it should be platform-specific. r=alexcrichton (bdfdbdd) r=brson (d803c18) r=alexcrichton (a5041d0) r=bstrie (317412a) r=alexcrichton (135c85e) r=thestinger (8805baa) r=pcwalton (0661178) r=cmr (9397fe0) r=cmr (caa4135) r=cmr (6a21d93) r=cmr (4dc3379) r=cmr (0aa5154) r=cmr (18be261) r=thestinger (f10be03)
Diffstat (limited to 'src/libstd/rt')
| -rw-r--r-- | src/libstd/rt/comm.rs | 29 | ||||
| -rw-r--r-- | src/libstd/rt/kill.rs | 3 | ||||
| -rw-r--r-- | src/libstd/rt/select.rs | 4 |
3 files changed, 28 insertions, 8 deletions
diff --git a/src/libstd/rt/comm.rs b/src/libstd/rt/comm.rs index 0cf223f3029..6dc44dd1193 100644 --- a/src/libstd/rt/comm.rs +++ b/src/libstd/rt/comm.rs @@ -508,7 +508,11 @@ impl<T> Peekable<T> for Port<T> { } } -impl<T> Select for Port<T> { +// XXX: Kind of gross. A Port<T> should be selectable so you can make an array +// of them, but a &Port<T> should also be selectable so you can select2 on it +// alongside a PortOne<U> without passing the port by value in recv_ready. + +impl<'self, T> Select for &'self Port<T> { #[inline] fn optimistic_check(&mut self) -> bool { do self.next.with_mut_ref |pone| { pone.optimistic_check() } @@ -526,12 +530,29 @@ impl<T> Select for Port<T> { } } -impl<T> SelectPort<(T, Port<T>)> for Port<T> { - fn recv_ready(self) -> Option<(T, Port<T>)> { +impl<T> Select for Port<T> { + #[inline] + fn optimistic_check(&mut self) -> bool { + (&*self).optimistic_check() + } + + #[inline] + fn block_on(&mut self, sched: &mut Scheduler, task: BlockedTask) -> bool { + (&*self).block_on(sched, task) + } + + #[inline] + fn unblock_from(&mut self) -> bool { + (&*self).unblock_from() + } +} + +impl<'self, T> SelectPort<T> for &'self Port<T> { + fn recv_ready(self) -> Option<T> { match self.next.take().recv_ready() { Some(StreamPayload { val, next }) => { self.next.put_back(next); - Some((val, self)) + Some(val) } None => None } diff --git a/src/libstd/rt/kill.rs b/src/libstd/rt/kill.rs index fbc9d1d2445..e07cb1425bf 100644 --- a/src/libstd/rt/kill.rs +++ b/src/libstd/rt/kill.rs @@ -590,7 +590,8 @@ impl Death { #[inline] pub fn assert_may_sleep(&self) { if self.wont_sleep != 0 { - rtabort!("illegal atomic-sleep: can't deschedule inside atomically()"); + rtabort!("illegal atomic-sleep: attempt to reschedule while \ + using an Exclusive or LittleLock"); } } } diff --git a/src/libstd/rt/select.rs b/src/libstd/rt/select.rs index 006b777b71b..84ce36c3e6b 100644 --- a/src/libstd/rt/select.rs +++ b/src/libstd/rt/select.rs @@ -199,9 +199,7 @@ mod test { // get it back out util::swap(port.get_mut_ref(), &mut ports[index]); // NB. Not recv(), because optimistic_check randomly fails. - let (data, new_port) = port.take_unwrap().recv_ready().unwrap(); - assert!(data == 31337); - port = Some(new_port); + assert!(port.get_ref().recv_ready().unwrap() == 31337); } } } |
