dope-core 0.77.0

Owned native I/O and completion driver for dope
Documentation
//! Zero-state projection of the current fiber poll's driver clock.

use std::task;

use crate::{driver::schedule::clock, executor::task::Fiber, executor::task::context};

/// Clock projection constructors for the active driver turn.
pub enum Clock {}

impl Clock {
    pub const fn now() -> Now {
        Now
    }
}

/// A zero-sized, one-poll clock projection. It uses no TLS, allocation, wake
/// slot, or scheduler credit beyond the poll which already executes it.
#[must_use = "a clock projection does nothing unless it is driven"]
pub struct Now;

impl<'d> Fiber<'d> for Now {
    type Output = clock::Moment<'d>;

    fn poll(call: context::PollCall<'_, '_, 'd, Self>) -> task::Poll<Self::Output> {
        let context = call.into_context();
        task::Poll::Ready(context.driver().driver_ref().clock().now())
    }
}

const _: () = assert!(std::mem::size_of::<Now>() == 0);