#[cfg(all(target_os = "linux", feature = "io-uring"))]
mod io_uring;
#[cfg(unix)]
mod unix;
#[cfg(target_os = "windows")]
mod windows;
#[cfg(all(target_os = "linux", feature = "xdp"))]
mod xdp;
use std::{
sync::Arc,
task::Wake,
thread::{self, Thread},
};
#[cfg(target_os = "windows")]
pub use self::windows::{TxRxTaskConfig, ethercat_now, tx_rx_task_blocking};
#[cfg(unix)]
pub use unix::{ethercat_now, tx_rx_task};
#[cfg(all(target_os = "linux", feature = "io-uring"))]
pub use io_uring::tx_rx_task_io_uring;
#[cfg(all(target_os = "linux", feature = "xdp"))]
pub use xdp::tx_rx_task_xdp;
struct ParkSignal {
current_thread: Thread,
}
impl ParkSignal {
fn new() -> Self {
Self {
current_thread: thread::current(),
}
}
fn wait(&self) {
thread::park();
}
}
impl Wake for ParkSignal {
fn wake(self: Arc<Self>) {
self.current_thread.unpark();
}
}