mirror of
https://github.com/tokio-rs/tokio.git
synced 2025-10-01 12:20:39 +00:00
metrics: fix compilation with unstable, process, and rt (#4682)
Fixes #4681.
This commit is contained in:
parent
593b042f7b
commit
4ec6ba8b76
@ -4,7 +4,7 @@
|
|||||||
//! these need to be available in the case when `net` is enabled but
|
//! these need to be available in the case when `net` is enabled but
|
||||||
//! `rt` is not.
|
//! `rt` is not.
|
||||||
|
|
||||||
cfg_not_rt_and_metrics! {
|
cfg_not_rt_and_metrics_and_net! {
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub(crate) struct IoDriverMetrics {}
|
pub(crate) struct IoDriverMetrics {}
|
||||||
|
|
||||||
@ -15,8 +15,10 @@ cfg_not_rt_and_metrics! {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg_rt! {
|
cfg_net! {
|
||||||
cfg_metrics! {
|
cfg_rt! {
|
||||||
pub(crate) use crate::runtime::IoDriverMetrics;
|
cfg_metrics! {
|
||||||
|
pub(crate) use crate::runtime::IoDriverMetrics;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -290,19 +290,21 @@ cfg_not_rt! {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg_metrics! {
|
cfg_net! {
|
||||||
impl Handle {
|
cfg_metrics! {
|
||||||
// TODO: Remove this when handle contains `Arc<Inner>` so that we can return
|
impl Handle {
|
||||||
// &IoDriverMetrics instead of using a closure.
|
// TODO: Remove this when handle contains `Arc<Inner>` so that we can return
|
||||||
//
|
// &IoDriverMetrics instead of using a closure.
|
||||||
// Related issue: https://github.com/tokio-rs/tokio/issues/4509
|
//
|
||||||
pub(crate) fn with_io_driver_metrics<F, R>(&self, f: F) -> Option<R>
|
// Related issue: https://github.com/tokio-rs/tokio/issues/4509
|
||||||
where
|
pub(crate) fn with_io_driver_metrics<F, R>(&self, f: F) -> Option<R>
|
||||||
F: Fn(&IoDriverMetrics) -> R,
|
where
|
||||||
{
|
F: Fn(&IoDriverMetrics) -> R,
|
||||||
self.inner().map(|inner| f(&inner.metrics))
|
{
|
||||||
}
|
self.inner().map(|inner| f(&inner.metrics))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Handle {
|
impl Handle {
|
||||||
|
@ -195,9 +195,19 @@ macro_rules! cfg_not_metrics {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! cfg_not_rt_and_metrics {
|
macro_rules! cfg_not_rt_and_metrics_and_net {
|
||||||
($($item:item)*) => {
|
($($item:item)*) => {
|
||||||
$( #[cfg(not(all(feature = "rt", all(tokio_unstable, not(loom)))))] $item )*
|
$( #[cfg(not(all(feature = "net", feature = "rt", all(tokio_unstable, not(loom)))))]$item )*
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
macro_rules! cfg_net_or_process {
|
||||||
|
($($item:item)*) => {
|
||||||
|
$(
|
||||||
|
#[cfg(any(feature = "net", feature = "process"))]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(any(feature = "net", feature = "process"))))]
|
||||||
|
$item
|
||||||
|
)*
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user