mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-09-08 00:00:13 +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:
@@ -11,8 +11,8 @@ mod platform {
|
||||
|
||||
pub async fn main() {
|
||||
// Create a stream for each of the signals we'd like to handle.
|
||||
let sigint = Signal::new(SIGINT).await.unwrap();
|
||||
let sigterm = Signal::new(SIGTERM).await.unwrap();
|
||||
let sigint = Signal::new(SIGINT).await.unwrap().map(|_| SIGINT);
|
||||
let sigterm = Signal::new(SIGTERM).await.unwrap().map(|_| SIGTERM);
|
||||
|
||||
// Use the `select` combinator to merge these two streams into one
|
||||
let stream = stream::select(sigint, sigterm);
|
||||
|
||||
@@ -20,12 +20,8 @@ mod platform {
|
||||
|
||||
// Up until now, we haven't really DONE anything, just prepared
|
||||
// our futures, now it's time to actually await the results!
|
||||
while let Some(the_signal) = stream.next().await {
|
||||
println!(
|
||||
"*Got signal {:#x}* I should probably reload my config \
|
||||
or something",
|
||||
the_signal
|
||||
);
|
||||
while let Some(_) = stream.next().await {
|
||||
println!("*Got signal* I should probably reload my config or something");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user