mirror of
https://github.com/denoland/deno.git
synced 2025-03-03 17:34:47 -05:00
chore: add conditional compilation for tokio_unstable feature (#19537)
Closes https://github.com/denoland/deno/issues/19528
This commit is contained in:
parent
faf6eaf2d3
commit
c8dc6b14ec
1 changed files with 6 additions and 0 deletions
|
@ -3,6 +3,7 @@ use std::fmt::Debug;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
use deno_core::task::MaskFutureAsSend;
|
use deno_core::task::MaskFutureAsSend;
|
||||||
|
#[cfg(tokio_unstable)]
|
||||||
use tokio_metrics::RuntimeMonitor;
|
use tokio_metrics::RuntimeMonitor;
|
||||||
|
|
||||||
/// Default configuration for tokio. In the future, this method may have different defaults
|
/// Default configuration for tokio. In the future, this method may have different defaults
|
||||||
|
@ -70,6 +71,7 @@ where
|
||||||
// SAFETY: this this is guaranteed to be running on a current-thread executor
|
// SAFETY: this this is guaranteed to be running on a current-thread executor
|
||||||
let future = unsafe { MaskFutureAsSend::new(future) };
|
let future = unsafe { MaskFutureAsSend::new(future) };
|
||||||
|
|
||||||
|
#[cfg(tokio_unstable)]
|
||||||
let join_handle = if metrics_enabled {
|
let join_handle = if metrics_enabled {
|
||||||
rt.spawn(async move {
|
rt.spawn(async move {
|
||||||
let metrics_interval: u64 = std::env::var("DENO_TOKIO_METRICS_INTERVAL")
|
let metrics_interval: u64 = std::env::var("DENO_TOKIO_METRICS_INTERVAL")
|
||||||
|
@ -93,6 +95,10 @@ where
|
||||||
} else {
|
} else {
|
||||||
rt.spawn(future)
|
rt.spawn(future)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#[cfg(not(tokio_unstable))]
|
||||||
|
let join_handle = rt.spawn(future);
|
||||||
|
|
||||||
rt.block_on(join_handle).unwrap().into_inner()
|
rt.block_on(join_handle).unwrap().into_inner()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue