[][src]Struct tokio_net::signal::unix::Signal

#[must_use = "streams do nothing unless polled"]
pub struct Signal { /* fields omitted */ }

An implementation of Stream for receiving a particular type of signal.

This structure implements the Stream trait and represents notifications of the current process receiving a particular signal. The signal being listened for is passed to Signal::new, and the same signal number is then yielded as each element for the stream.

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 mind when using Signal streams:

  • Signals handling in Unix already necessitates coalescing signals together sometimes. This Signal stream is also no exception here in that it will also coalesce signals. That is, even if the signal handler for this process runs multiple times, the Signal stream may only return one signal notification. Specifically, before poll is called, all signal notifications are coalesced into one item returned from poll. 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 at least one signal, but possibly more.

  • Signal handling in general is relatively inefficient. Although some improvements are possible in this crate, it's recommended to not plan on having millions of signal channels open.

  • Currently the "driver task" to process incoming signals never exits. This driver task runs in the background of the event loop provided, and in general you shouldn't need to worry about it.

If you've got any questions about this feel free to open an issue on the repo, though, as I'd love to chat about this! In other words, I'd love to alleviate some of these limitations if possible!

Trait Implementations

impl Debug for Signal[src]

impl Stream for Signal[src]

type Item = ()

Values yielded by the stream.

Auto Trait Implementations

impl Send for Signal

impl Unpin for Signal

impl Sync for Signal

impl !RefUnwindSafe for Signal

impl !UnwindSafe for Signal

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> StreamExt for T where
    T: Stream + ?Sized
[src]