use crate::{
ConcurrentMode, ConcurrentRuntime, ConfiguredRuntime, DefaultIdlePolicy, ExecutorClock,
ExecutorHooks, IdlePolicy, ManualClock, NoHooks, RuntimeOptions, RuntimeQueues, SpawnError,
TaskHandle,
};
use pi_async_executor::{IdleBinding, ThreadNotifier, TimerBinding};
use pi_async_task_queue::InternalTaskQueue;
use pi_async_task_queue::{QueueSelection, WeightedSerialParQueue};
use pi_clock_manual::global::GlobalManualInstant;
use std::future::Future;
pub type WeightedRuntime = ConfiguredRuntime<
ConcurrentMode,
ManualClock,
DefaultIdlePolicy,
NoHooks,
WeightedSerialParQueue,
>;
impl WeightedRuntime {
pub fn new_weighted() -> pi_result::Result<Self> {
weighted_runtime_new_inner(RuntimeOptions::default())
}
pub fn with_weighted_options(options: RuntimeOptions) -> pi_result::Result<Self> {
weighted_runtime_new_inner(options)
}
}
impl<C, P, H, I, T, Q> ConfiguredRuntime<ConcurrentMode, C, P, H, WeightedSerialParQueue, I, T, Q>
where
C: ExecutorClock<Instant = GlobalManualInstant>,
P: IdlePolicy,
H: ExecutorHooks,
I: IdleBinding,
T: TimerBinding<ClockInstant = GlobalManualInstant>,
Q: InternalTaskQueue + 'static,
{
pub fn spawn_with_queue<F>(
&self,
future: F,
queue: QueueSelection,
) -> pi_result::RawResult<TaskHandle<F::Output>, SpawnError<F, ThreadNotifier>>
where
F: Future + Send + 'static,
F::Output: Send + 'static,
{
self.shared().spawn_with_queue(future, queue)
}
}
include!("weighted_runtime_inner.rs");