#[cfg(any(windows, target_os = "macos"))]
use std::sync::OnceLock;
use std::time::Duration;
#[cfg(any(windows, target_os = "macos"))]
use tokio::sync::{Semaphore, SemaphorePermit};
#[cfg(any(windows, target_os = "macos"))]
const RESOURCE_INTENSIVE_TEST_CONCURRENCY: usize = 1;
#[cfg(any(windows, target_os = "macos"))]
pub(crate) async fn resource_intensive_test_permit() -> SemaphorePermit<'static> {
static PERMITS: OnceLock<Semaphore> = OnceLock::new();
PERMITS
.get_or_init(|| Semaphore::new(RESOURCE_INTENSIVE_TEST_CONCURRENCY))
.acquire()
.await
.expect("resource-intensive test semaphore must remain open")
}
#[cfg(not(any(windows, target_os = "macos")))]
pub(crate) async fn resource_intensive_test_permit() {}
pub(crate) const fn external_resource_start_timeout(default: Duration) -> Duration {
#[cfg(any(windows, target_os = "macos"))]
{
if default.as_secs() < 30 {
return Duration::from_secs(30);
}
}
default
}