#[allow(unused_variables)]
fn runtime_new_inner<M, E, I, F, T, Q, B>(
options: RuntimeOptions,
queues: RuntimeQueues<ManualClock, E, I, F, B>,
) -> pi_result::Result<ConfiguredRuntime<M, ManualClock, DefaultIdlePolicy, NoHooks, E, I, T, Q>>
where
M: RuntimeMode + QueuePair<E, Q>,
E: ExternalQueueManager,
I: IdleBinding,
T: TimerBinding<ClockInstant = GlobalManualInstant>,
Q: InternalTaskQueue + 'static,
F: RuntimeTimerFactory<ManualClock, T, Q>,
B: RuntimeInternalFactory<Q>,
{
runtime_components_inner::<M, ManualClock, DefaultIdlePolicy, NoHooks, E, I, F, T, Q, B>(
|| if T::PRESENT { ManualClock::new() } else { Ok(ManualClock) },
DefaultIdlePolicy, NoHooks, options, queues,
)
}
#[allow(unused_variables)]
fn runtime_components_inner<M, C, P, H, E, I, F, T, Q, B>(
make_clock: impl FnOnce() -> pi_result::Result<C>,
policy: P,
hooks: H,
options: RuntimeOptions,
queues: RuntimeQueues<C, E, I, F, B>,
) -> pi_result::Result<ConfiguredRuntime<M, C, P, H, E, I, T, Q>>
where
M: RuntimeMode + QueuePair<E, Q>,
C: ExecutorClock<Instant = GlobalManualInstant>,
E: ExternalQueueManager,
I: IdleBinding,
T: TimerBinding<ClockInstant = GlobalManualInstant>,
Q: InternalTaskQueue + 'static,
P: IdlePolicy,
H: ExecutorHooks,
F: RuntimeTimerFactory<C, T, Q>,
B: RuntimeInternalFactory<Q>,
{
use crate::{
binding::RuntimeTag,
lifecycle::{RuntimeBinding, RuntimeExternalSource},
queues::QueueSelection,
};
<M as QueuePair<E, Q>>::validate_external()?;
let clock = make_clock()?;
let binding = RuntimeBinding::new();
let executor_options = options.executor;
let timer_options = options.timer;
let external = match queues.external {
QueueSelection::Specified(value) => value,
QueueSelection::Default(make) => make(options.external_queue)?,
};
let idle = match queues.idle {
QueueSelection::Specified(value) => value,
QueueSelection::Default(make) => make(options.idle_queue)?,
};
let source = RuntimeExternalSource::new(external, Rc::clone(&binding));
let executor = queues.internal.bind::<C, RuntimeExternalSource<E>, I, T, RuntimeTag<C, T, Q>>(
clock, source, idle, executor_options, queues.timer.prepare(timer_options),
)?;
Ok(ConfiguredRuntime::from_executor(executor, binding, policy, hooks))
}
fn runtime_from_executor_inner<M, C, P, H, E, I, T, Q>(
executor: Executor<C, E, I, T, Q>,
binding: Rc<RuntimeBinding>,
policy: P,
hooks: H,
) -> ConfiguredRuntime<M, C, P, H, E, I, T, Q>
where
M: RuntimeMode,
C: ExecutorClock<Instant = GlobalManualInstant>,
E: RuntimeSourceBinding,
I: IdleBinding,
T: TimerBinding<ClockInstant = GlobalManualInstant>,
Q: InternalTaskQueue + 'static,
P: IdlePolicy,
H: ExecutorHooks,
{
let handle = executor.handle();
let shared = RuntimeHandle { inner: Arc::new(handle) };
let data = RuntimeData {
executor,
mode: M::default(),
policy,
hooks,
};
ConfiguredRuntime {
shared,
data: RefCell::new(Some(data)),
binding,
}
}
#[allow(unused_variables)]
fn runtime_handle_clone_inner<C, E, I, T, Q>(this: &RuntimeHandle<C, E, I, T, Q>) -> RuntimeHandle<C, E, I, T, Q>
where
C: ExecutorClock<Instant = GlobalManualInstant>,
E: ExternalAccess,
I: IdleAccess,
T: TimerBinding<ClockInstant = GlobalManualInstant>,
Q: InternalTaskQueue + 'static,
{
RuntimeHandle { inner: std::sync::Arc::clone(&this.inner) }
}
#[allow(unused_variables)]
fn runtime_drop_inner<M, C, P, H, E, I, T, Q>(this: &mut ConfiguredRuntime<M, C, P, H, E, I, T, Q>)
where
M: RuntimeMode,
C: ExecutorClock<Instant = GlobalManualInstant>,
E: RuntimeSourceBinding,
I: IdleBinding,
T: TimerBinding<ClockInstant = GlobalManualInstant>,
Q: InternalTaskQueue + 'static,
P: IdlePolicy,
H: ExecutorHooks,
{
this.binding.revoke();
let data = this.data.get_mut().take();
drop(data);
}