You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
extern mod std;
use core::pipes::*;
use std::comm::DuplexStream;
use core::task;
fn main () {
let (chan, port): (Chan<int>, Port<int>) = stream();
do task::spawn() |move port| {
assert port.recv() == 123;
assert !port.peek();
}
chan.send(123);
}
Wow, I should pay more attention to these threads :)
The original behavior (closed pipes return true) was intentional on my part. The rational is that peek returns true when something has happened on the pipe that you might care about. For example, if we had a loop that kept using peek to test for a message, we'd want to know if the pipe closed so we could terminate the loop.
That said, I can see the argument for the new behavior, so I'm fine if people would rather it be the other way. Perhaps we could have peek that returns an enum of MessageWaiting, Terminated or NoData.
There is no message available but peek returns true, likely because this: https://github.com/mozilla/rust/blob/incoming/src/libcore/pipes.rs#L516
I expect that anytime
peek
returns true I can callrecv
successfully.The text was updated successfully, but these errors were encountered: