use core::time::Duration;
use crate::core::line::CompletionLine;
#[cfg(all(target_arch = "aarch64", target_os = "linux"))]
#[path = "wordwait_arm64.rs"]
mod arch;
#[cfg(all(target_arch = "x86_64", target_os = "linux"))]
#[path = "wordwait_x86.rs"]
mod arch;
#[cfg(not(any(
all(target_arch = "aarch64", target_os = "linux"),
all(target_arch = "x86_64", target_os = "linux")
)))]
mod arch {
use super::{CompletionLine, Duration};
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct WordWait {
_none: (),
}
impl WordWait {
pub(super) fn probe_arch() -> Result<Self, &'static str> {
Err("no user-mode word wait on this target (aarch64 or x86-64 Linux only)")
}
pub(super) fn park_arch(
&self,
line: &CompletionLine,
ready: impl Fn(&CompletionLine) -> bool,
_bound: Duration,
) -> bool {
ready(line)
}
}
}
pub use arch::WordWait;
#[cfg(all(target_arch = "x86_64", target_os = "linux"))]
pub use arch::Flavor;
impl WordWait {
pub fn probe() -> Result<Self, &'static str> {
Self::probe_arch()
}
#[must_use]
pub fn park(
&self,
line: &CompletionLine,
ready: impl Fn(&CompletionLine) -> bool,
bound: Duration,
) -> bool {
self.park_arch(line, ready, bound)
}
}