mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-09-08 00:00:13 +02:00
signal: Add SignalKind for registering signals more easily (#1430)
This avoids having consumers import libc for common signals, and it improves discoverability since users need not be aware that libc contains all supported constants.
This commit is contained in:
@@ -6,18 +6,18 @@ use libc;
|
||||
pub mod support;
|
||||
use crate::support::*;
|
||||
|
||||
const TEST_SIGNAL: libc::c_int = libc::SIGUSR1;
|
||||
|
||||
#[test]
|
||||
fn dropping_loops_does_not_cause_starvation() {
|
||||
let (mut rt, signal) = {
|
||||
let kind = SignalKind::sigusr1();
|
||||
|
||||
let mut first_rt = CurrentThreadRuntime::new().expect("failed to init first runtime");
|
||||
let mut first_signal = Signal::new(TEST_SIGNAL).expect("failed to register first signal");
|
||||
let mut first_signal = Signal::new(kind).expect("failed to register first signal");
|
||||
|
||||
let mut second_rt = CurrentThreadRuntime::new().expect("failed to init second runtime");
|
||||
let mut second_signal = Signal::new(TEST_SIGNAL).expect("failed to register second signal");
|
||||
let mut second_signal = Signal::new(kind).expect("failed to register second signal");
|
||||
|
||||
send_signal(TEST_SIGNAL);
|
||||
send_signal(libc::SIGUSR1);
|
||||
|
||||
let _ = run_with_timeout(&mut first_rt, first_signal.next())
|
||||
.expect("failed to await first signal");
|
||||
@@ -31,7 +31,7 @@ fn dropping_loops_does_not_cause_starvation() {
|
||||
(second_rt, second_signal)
|
||||
};
|
||||
|
||||
send_signal(TEST_SIGNAL);
|
||||
send_signal(libc::SIGUSR1);
|
||||
|
||||
let _ = run_with_timeout(&mut rt, signal.into_future());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user