Skip to content

Commit

Permalink
signal: updated Documentation for Signals (tokio-rs#5459)
Browse files Browse the repository at this point in the history
  • Loading branch information
ericmcbride authored and amab8901 committed Feb 27, 2023
1 parent 0bdb3e9 commit 3164fe6
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 70 deletions.
14 changes: 9 additions & 5 deletions tokio/src/signal/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,11 @@ fn signal_enable(signal: SignalKind, handle: &Handle) -> io::Result<()> {
}
}

/// A stream of events for receiving a particular type of OS signal.
/// An listener for receiving a particular type of OS signal.
///
/// The listener can be turned into a `Stream` using [`SignalStream`].
///
/// [`SignalStream`]: https://docs.rs/tokio-stream/latest/tokio_stream/wrappers/struct.SignalStream.html
///
/// In general signal handling on Unix is a pretty tricky topic, and this
/// structure is no exception! There are some important limitations to keep in
Expand All @@ -307,7 +311,7 @@ fn signal_enable(signal: SignalKind, handle: &Handle) -> io::Result<()> {
/// Once `poll` has been called, however, a further signal is guaranteed to
/// be yielded as an item.
///
/// Put another way, any element pulled off the returned stream corresponds to
/// Put another way, any element pulled off the returned listener corresponds to
/// *at least one* signal, but possibly more.
///
/// * Signal handling in general is relatively inefficient. Although some
Expand Down Expand Up @@ -345,11 +349,11 @@ fn signal_enable(signal: SignalKind, handle: &Handle) -> io::Result<()> {
/// #[tokio::main]
/// async fn main() -> Result<(), Box<dyn std::error::Error>> {
/// // An infinite stream of hangup signals.
/// let mut stream = signal(SignalKind::hangup())?;
/// let mut sig = signal(SignalKind::hangup())?;
///
/// // Print whenever a HUP signal is received
/// loop {
/// stream.recv().await;
/// sig.recv().await;
/// println!("got signal HUP");
/// }
/// }
Expand All @@ -360,7 +364,7 @@ pub struct Signal {
inner: RxFuture,
}

/// Creates a new stream which will receive notifications when the current
/// Creates a new listener which will receive notifications when the current
/// process receives the specified signal `kind`.
///
/// This function will create a new stream which binds to the default reactor.
Expand Down
Loading

0 comments on commit 3164fe6

Please sign in to comment.