Skip to content

Commit e239ec1

Browse files
huonwalexcrichton
authored andcommitted
---
yaml --- r: 108249 b: refs/heads/dist-snap c: 411a01f h: refs/heads/master i: 108247: 0bffb93 v: v3
1 parent b7e9312 commit e239ec1

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: f64fdf524a434f0e5cd0bc91d09c144723f3c90d
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/dist-snap: 866d6cc33d06050b546abbe5930546ff17d96493
9+
refs/heads/dist-snap: 411a01feb302dd64b669658562f2052decc80f19
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1212
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/src/libstd/comm/select.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -60,21 +60,17 @@ use uint;
6060

6161
macro_rules! select {
6262
(
63-
$name1:pat = $port1:ident.$meth1:ident() => $code1:expr,
64-
$($name:pat = $port:ident.$meth:ident() => $code:expr),*
63+
$($name:pat = $port:ident.$meth:ident() => $code:expr),+
6564
) => ({
6665
use std::comm::Select;
6766
let sel = Select::new();
68-
let mut $port1 = sel.handle(&$port1);
69-
$( let mut $port = sel.handle(&$port); )*
67+
$( let mut $port = sel.handle(&$port); )+
7068
unsafe {
71-
$port1.add();
72-
$( $port.add(); )*
69+
$( $port.add(); )+
7370
}
7471
let ret = sel.wait();
75-
if ret == $port1.id { let $name1 = $port1.$meth1(); $code1 }
76-
$( else if ret == $port.id { let $name = $port.$meth(); $code } )*
77-
else { unreachable!() }
72+
$( if ret == $port.id() { let $name = $port.$meth(); $code } else )+
73+
{ unreachable!() }
7874
})
7975
}
8076

@@ -94,7 +90,7 @@ pub struct Select {
9490
pub struct Handle<'port, T> {
9591
/// The ID of this handle, used to compare against the return value of
9692
/// `Select::wait()`
97-
id: uint,
93+
priv id: uint,
9894
priv selector: &'port Select,
9995
priv next: *mut Handle<'static, ()>,
10096
priv prev: *mut Handle<'static, ()>,
@@ -150,7 +146,7 @@ impl Select {
150146

151147
/// Waits for an event on this port set. The returned valus is *not* and
152148
/// index, but rather an id. This id can be queried against any active
153-
/// `Handle` structures (each one has a public `id` field). The handle with
149+
/// `Handle` structures (each one has an `id` method). The handle with
154150
/// the matching `id` will have some sort of event available on it. The
155151
/// event could either be that data is available or the corresponding
156152
/// channel has been closed.
@@ -242,6 +238,10 @@ impl Select {
242238
}
243239

244240
impl<'port, T: Send> Handle<'port, T> {
241+
/// Retrieve the id of this handle.
242+
#[inline]
243+
pub fn id(&self) -> uint { self.id }
244+
245245
/// Receive a value on the underlying port. Has the same semantics as
246246
/// `Port.recv`
247247
pub fn recv(&mut self) -> T { self.port.recv() }
@@ -355,7 +355,7 @@ mod test {
355355
)
356356
drop(c2);
357357
select! (
358-
bar = p2.recv_opt() => { assert_eq!(bar, None); },
358+
bar = p2.recv_opt() => { assert_eq!(bar, None); }
359359
)
360360
})
361361

0 commit comments

Comments
 (0)