use crate::parking::PreparedThreadParker;
use pi_async_task_queue::timer::{TimerQueueError, TimerQueueStatus, TimerTaskQueue};
use pi_async_runtime_core::task::RuntimeIdReservation;
impl<C, E, I, T, L> DefaultExecutor<C, E, I, T, L>
where
C: ExecutorClock,
E: ExternalQueueManager,
I: IdleBinding,
T: ExecutorTimer<Instant = C::Instant> + 'static,
L: LocalReadySubmit,
{
#[doc(hidden)]
pub fn from_prepared(
clock: C,
identity: RuntimeIdReservation,
stable_notice: PreparedThreadParker,
external: E,
idle: I,
options: ExecutorOptions,
make_timer: impl FnOnce(RuntimeId, &C, ThreadNotifier) -> pi_result::Result<T>,
) -> pi_result::Result<(Self, crate::handle::ExecutorMemberAccess<E::Handle, I::Handle, T, L>)> {
executor_from_prepared_inner(
clock, identity, stable_notice, external, idle, options,
move |runtime, clock, notifier, slot| {
prepare_bound_timer(runtime, clock, notifier, slot, make_timer)
},
)
}
}
impl<C, E, I, L> DefaultExecutor<C, E, I, crate::NoTimerQueue<C::Instant>, L>
where
C: ExecutorClock,
E: ExternalQueueManager,
I: IdleBinding,
L: LocalReadySubmit,
{
#[doc(hidden)]
pub fn from_prepared_without_timer(
clock: C,
identity: RuntimeIdReservation,
stable_notice: PreparedThreadParker,
external: E,
idle: I,
options: ExecutorOptions,
) -> pi_result::Result<(Self, crate::handle::ExecutorMemberAccess<E::Handle, I::Handle, crate::NoTimerQueue<C::Instant>, L>)> {
executor_from_prepared_inner(
clock, identity, stable_notice, external, idle, options, |_, _, _, _| Ok(()),
)
}
}
fn prepare_bound_timer<C, T>(
runtime: RuntimeId,
clock: &C,
notifier: &ThreadNotifier,
slot: &mut Option<T>,
make_timer: impl FnOnce(RuntimeId, &C, ThreadNotifier) -> pi_result::Result<T>,
) -> pi_result::Result<T::Access>
where
C: ExecutorClock,
T: ExecutorTimer<Instant = C::Instant> + 'static,
{
prepare_bound_timer_inner(runtime, clock, notifier, slot, make_timer)
}
include!("prepared_executor_inner.rs");