rustzmq2 0.1.0

A native async Rust implementation of ZeroMQ
Documentation
//! Runtime-agnostic kernel-fd signaler.
//!
//! Edge-triggered, coalescing, single-bit cross-task wakeup. Mirrors
//! libzmq's `signaler_t` (eventfd on Linux, pipe on other unix, userspace
//! fallback on Windows) and replaces `tokio::sync::Notify` /
//! `event_listener::Event` on RTT-critical paths.
//!
//! ```text
//! signaler/
//!   mod.rs  — trait + RuntimeSignaler alias
//!   os.rs   — OS-level fd helpers (eventfd, pipe), no runtime cfg
//!   tokio.rs — TokioSignaler over tokio::io::unix::AsyncFd
//!   smol.rs  — SmolSignaler over async_io::Async
//! ```

use std::future::Future;

#[cfg(unix)]
pub(crate) mod os;

#[cfg(all(feature = "smol", not(feature = "tokio")))]
pub(crate) mod smol;
#[cfg(feature = "tokio")]
pub(crate) mod tokio;

#[cfg(test)]
mod tests;

/// Cross-task wakeup primitive. `signal()` and `signaled()` are split-half:
/// any thread can call `signal()`, exactly one task awaits `signaled()` at
/// a time. Multiple `signal()` calls between awaits coalesce into one wake.
pub(crate) trait AsyncSignaler: Send + Sync + 'static {
    /// Fire a wake. Never blocks; lossless coalescing.
    fn signal(&self);

    /// Wait for the next signal. Cancel-safe — dropping the future before
    /// completion does not lose the signal (the next `signaled()` will
    /// observe it).
    fn signaled(&self) -> impl Future<Output = ()> + Send + '_;
}

#[cfg(all(feature = "smol", not(feature = "tokio")))]
#[allow(unused_imports)]
pub(crate) use self::smol::SmolSignaler as RuntimeSignaler;
#[cfg(feature = "tokio")]
#[allow(unused_imports)]
pub(crate) use self::tokio::TokioSignaler as RuntimeSignaler;