Skip to content

Commit 8d9cc2a

Browse files
huonwalexcrichton
authored andcommitted
---
yaml --- r: 104146 b: refs/heads/try c: 411a01f h: refs/heads/master v: v3
1 parent 75b1f7e commit 8d9cc2a

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
@@ -2,7 +2,7 @@
22
refs/heads/master: 62f1d68439dcfd509eaca29887afa97f22938373
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 6e7f170fedd3c526a643c0b2d13863acd982be02
5-
refs/heads/try: 866d6cc33d06050b546abbe5930546ff17d96493
5+
refs/heads/try: 411a01feb302dd64b669658562f2052decc80f19
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/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)