use pi_async_task::definitions::TaskId;
use pi_async_task_queue::cancel_timer::PreparedCancelTimerQueue;
#[doc(hidden)]
pub struct PreparedDefaultTimer<C, L>
where
C: ExecutorClock<Instant = GlobalManualInstant>,
L: LocalTimerSubmit<DefaultTimerItem<C, L>>,
{
queue: Option<PreparedCancelTimerQueue<DefaultTimerItem<C, L>, ThreadNotifier>>,
access: DefaultTimerAccess<C, L>,
retry: Option<RetryOwner<CancelRetryNode<C, L>>>,
}
struct TimerAdmission {
may_admit: Box<dyn Fn(TaskId) -> Option<bool>>,
}
impl<C, L> PreparedDefaultTimer<C, L>
where
C: ExecutorClock<Instant = GlobalManualInstant>,
L: LocalTimerSubmit<DefaultTimerItem<C, L>>,
{
pub fn prepare(runtime: RuntimeId, clock: C, notifier: ThreadNotifier, options: CancelTimerOptions) -> pi_result::Result<Self> {
prepare_default_timer_inner(runtime, clock, notifier, options)
}
pub fn access(&self) -> DefaultTimerAccess<C, L> {
prepared_default_timer_access_inner(self)
}
pub fn bind(self, notifier: &ThreadNotifier, now: GlobalManualInstant,
may_admit: impl Fn(TaskId) -> Option<bool> + 'static) -> pi_result::Result<DefaultTimerDriver<C, L>> {
bind_default_timer_inner(self, notifier, now, may_admit)
}
}
impl<C, L> Drop for PreparedDefaultTimer<C, L> where C: ExecutorClock<Instant = GlobalManualInstant>, L: LocalTimerSubmit<DefaultTimerItem<C, L>> {
fn drop(&mut self) {
prepared_default_timer_drop_inner(self)
}
}
include!("prepared_default_timer_inner.rs");