From 81a77943d73d89eb265bada4afe5bf70b19fb726 Mon Sep 17 00:00:00 2001 From: Kevin Ballard Date: Wed, 12 Feb 2014 12:55:46 -0800 Subject: [PATCH] Reintroduce std::comm::Handle.try_recv() --- src/libstd/comm/select.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libstd/comm/select.rs b/src/libstd/comm/select.rs index b6b35ccc35790..54500d8a8e603 100644 --- a/src/libstd/comm/select.rs +++ b/src/libstd/comm/select.rs @@ -55,7 +55,7 @@ use ptr::RawPtr; use result::{Ok, Err, Result}; use rt::local::Local; use rt::task::{Task, BlockedTask}; -use super::Port; +use super::{Port, TryRecvResult}; use uint; macro_rules! select { @@ -249,6 +249,9 @@ impl<'port, T: Send> Handle<'port, T> { /// success or `None` if the channel disconnects. This function has the same /// semantics as `Port.recv_opt` pub fn recv_opt(&mut self) -> Option { self.port.recv_opt() } + /// Immediately attempt to receive a value on a port, this function will + /// never block. Has the same semantics as `Port.try_recv`. + pub fn try_recv(&mut self) -> TryRecvResult { self.port.try_recv() } /// Adds this handle to the port set that the handle was created from. This /// method can be called multiple times, but it has no effect if `add` was