mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-09-07 00:00:08 +02:00
signal: change unix::Signal to return () instead of signum (#1330)
* This simplifies the API surface by returning () instead of the signal number that was used during registration. This also more closely mirrors the cross-platform `CtrlC` event stream API * This is a **breaking change**
This commit is contained in:
@@ -254,7 +254,6 @@ impl Driver {
|
||||
#[derive(Debug)]
|
||||
pub struct Signal {
|
||||
driver: Driver,
|
||||
signal: c_int,
|
||||
rx: Receiver<()>,
|
||||
}
|
||||
|
||||
@@ -321,7 +320,7 @@ impl Signal {
|
||||
let (tx, rx) = channel(1);
|
||||
globals().register_listener(signal as EventId, tx);
|
||||
|
||||
Ok(Signal { driver, rx, signal })
|
||||
Ok(Signal { driver, rx })
|
||||
})
|
||||
.boxed()
|
||||
}
|
||||
@@ -332,12 +331,12 @@ impl Signal {
|
||||
}
|
||||
|
||||
impl Stream for Signal {
|
||||
type Item = c_int;
|
||||
type Item = ();
|
||||
|
||||
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
|
||||
let _ = Pin::new(&mut self.driver).poll(cx);
|
||||
|
||||
self.rx.poll_recv(cx).map(|item| item.map(|()| self.signal))
|
||||
self.rx.poll_recv(cx)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user