mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-09-08 00:00:13 +02:00
signal: specialize unix OsStorage (#7818)
This commit is contained in:
@@ -18,21 +18,25 @@ use std::sync::atomic::{AtomicBool, Ordering};
|
|||||||
use std::sync::Once;
|
use std::sync::Once;
|
||||||
use std::task::{Context, Poll};
|
use std::task::{Context, Poll};
|
||||||
|
|
||||||
|
#[cfg(not(any(target_os = "linux", target_os = "illumos")))]
|
||||||
|
pub(crate) type OsStorage = [SignalInfo; 34];
|
||||||
|
|
||||||
|
#[cfg(any(target_os = "linux", target_os = "illumos"))]
|
||||||
pub(crate) type OsStorage = Box<[SignalInfo]>;
|
pub(crate) type OsStorage = Box<[SignalInfo]>;
|
||||||
|
|
||||||
impl Init for OsStorage {
|
impl Init for OsStorage {
|
||||||
fn init() -> Self {
|
fn init() -> Self {
|
||||||
// There are reliable signals ranging from 1 to 33 available on every Unix platform.
|
// There are reliable signals ranging from 1 to 33 available on every Unix platform.
|
||||||
#[cfg(not(any(target_os = "linux", target_os = "illumos")))]
|
#[cfg(not(any(target_os = "linux", target_os = "illumos")))]
|
||||||
let possible = 0..=33;
|
return std::array::from_fn(|_| SignalInfo::default());
|
||||||
|
|
||||||
// On Linux and illumos, there are additional real-time signals
|
// On Linux and illumos, there are additional real-time signals
|
||||||
// available. (This is also likely true on Solaris, but this should be
|
// available. (This is also likely true on Solaris, but this should be
|
||||||
// verified before being enabled.)
|
// verified before being enabled.)
|
||||||
#[cfg(any(target_os = "linux", target_os = "illumos"))]
|
#[cfg(any(target_os = "linux", target_os = "illumos"))]
|
||||||
let possible = 0..=libc::SIGRTMAX();
|
return std::iter::repeat_with(SignalInfo::default)
|
||||||
|
.take(libc::SIGRTMAX() as usize + 1)
|
||||||
possible.map(|_| SignalInfo::default()).collect()
|
.collect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user