diff options
author | Carl Lerche <me@carllerche.com> | 2020-09-24 17:26:38 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-24 17:26:38 -0700 |
commit | cf025ba45f68934ae2138bb75ee2a5ee50506d1b (patch) | |
tree | 39fa03f4b063402e84da4435ebca39bd21266ad2 /tokio/src/signal | |
parent | 4186b0aa38abbec7670d53882d5cdfd4b12add5c (diff) |
sync: support mpsc send with `&self` (#2861)
Updates the mpsc channel to use the intrusive waker based sempahore.
This enables using `Sender` with `&self`.
Instead of using `Sender::poll_ready` to ensure capacity and updating
the `Sender` state, `async fn Sender::reserve()` is added. This function
returns a `Permit` value representing the reserved capacity.
Fixes: #2637
Refs: #2718 (intrusive waiters)
Diffstat (limited to 'tokio/src/signal')
-rw-r--r-- | tokio/src/signal/unix.rs | 30 |
1 files changed, 1 insertions, 29 deletions
diff --git a/tokio/src/signal/unix.rs b/tokio/src/signal/unix.rs index 45a091d7..30a05872 100644 --- a/tokio/src/signal/unix.rs +++ b/tokio/src/signal/unix.rs @@ -391,35 +391,7 @@ impl Signal { poll_fn(|cx| self.poll_recv(cx)).await } - /// Polls to receive the next signal notification event, outside of an - /// `async` context. - /// - /// `None` is returned if no more events can be received by this stream. - /// - /// # Examples - /// - /// Polling from a manually implemented future - /// - /// ```rust,no_run - /// use std::pin::Pin; - /// use std::future::Future; - /// use std::task::{Context, Poll}; - /// use tokio::signal::unix::Signal; - /// - /// struct MyFuture { - /// signal: Signal, - /// } - /// - /// impl Future for MyFuture { - /// type Output = Option<()>; - /// - /// fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { - /// println!("polling MyFuture"); - /// self.signal.poll_recv(cx) - /// } - /// } - /// ``` - pub fn poll_recv(&mut self, cx: &mut Context<'_>) -> Poll<Option<()>> { + pub(crate) fn poll_recv(&mut self, cx: &mut Context<'_>) -> Poll<Option<()>> { self.rx.poll_recv(cx) } } |