std::select: Use correct indices from the front
Caught a bug where .enumerate() was used on a reverse iterator. The indices should be counted from the front here (bblum confirms).
This commit is contained in:
parent
46a6dbc541
commit
43ef5ad184
@ -11,7 +11,7 @@
|
|||||||
use cell::Cell;
|
use cell::Cell;
|
||||||
use comm;
|
use comm;
|
||||||
use container::Container;
|
use container::Container;
|
||||||
use iterator::Iterator;
|
use iterator::{Iterator, DoubleEndedIterator};
|
||||||
use option::*;
|
use option::*;
|
||||||
// use either::{Either, Left, Right};
|
// use either::{Either, Left, Right};
|
||||||
// use rt::kill::BlockedTask;
|
// use rt::kill::BlockedTask;
|
||||||
@ -87,7 +87,7 @@ pub fn select<A: Select>(ports: &mut [A]) -> uint {
|
|||||||
// Task resumes. Now unblock ourselves from all the ports we blocked on.
|
// Task resumes. Now unblock ourselves from all the ports we blocked on.
|
||||||
// If the success index wasn't reset, 'take' will just take all of them.
|
// If the success index wasn't reset, 'take' will just take all of them.
|
||||||
// Iterate in reverse so the 'earliest' index that's ready gets returned.
|
// Iterate in reverse so the 'earliest' index that's ready gets returned.
|
||||||
for (index, port) in ports.mut_slice(0, ready_index).mut_rev_iter().enumerate() {
|
for (index, port) in ports.mut_slice(0, ready_index).mut_iter().enumerate().invert() {
|
||||||
if port.unblock_from() {
|
if port.unblock_from() {
|
||||||
ready_index = index;
|
ready_index = index;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user