mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-27 00:00:12 +02:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user