sync: add async APIs to oneshot and mpsc (#1211)

Adds:

- oneshot::Sender::close
- mpsc::Receiver::recv
- mpsc::Sender::send

Also renames `poll_next` to `poll_recv`.

Refs: #1210
This commit is contained in:
Carl Lerche
2019-06-27 11:33:36 -07:00
committed by GitHub
parent 0af05e7408
commit 32ceccb465
10 changed files with 143 additions and 41 deletions
+8 -1
View File
@@ -88,10 +88,17 @@ impl<T> UnboundedReceiver<T> {
}
/// TODO: dox
pub fn poll_next(&mut self, cx: &mut Context<'_>) -> Poll<Option<T>> {
pub fn poll_recv(&mut self, cx: &mut Context<'_>) -> Poll<Option<T>> {
self.chan.recv(cx)
}
/// TODO: Dox
pub async fn recv(&mut self) -> Option<T> {
use async_util::future::poll_fn;
poll_fn(|cx| self.poll_recv(cx)).await
}
/// Closes the receiving half of a channel, without dropping it.
///
/// This prevents any further messages from being sent on the channel while