pi_async_executor/
drive.rs1use pi_async_runtime_core::definitions::{RuntimeId, RuntimeStatus};
3use std::{num::NonZeroUsize, time::Duration};
4
5pub trait AdmissionRule {
7 fn admits_external(&self, state: &AdmissionState) -> bool;
9}
10#[derive(Clone, Copy, Debug)]
12pub struct AdmissionState {
13 pub runtime: RuntimeId,
14 pub status: RuntimeStatus,
15 pub internal_tasks: usize,
17 pub in_flight_tasks: usize,
19}
20#[derive(Clone, Copy, Debug, Eq, PartialEq)]
22pub enum TimerDelivery {
23 One,
24 All,
25}
26#[derive(Clone, Copy, Debug)]
28pub struct ExecutorOptions {
29 pub maintenance_batch: NonZeroUsize,
31 pub would_block_retries: u8,
33 pub timer_delivery: TimerDelivery,
35 pub max_sleep: Duration,
37}
38impl Default for ExecutorOptions {
39 fn default() -> Self {
40 executor_options_default_inner()
41 }
42}
43impl ExecutorOptions {
44 pub fn validate(&self) -> pi_result::Result<()> {
46 executor_options_validate_inner(self)
47 }
48}
49#[derive(Clone, Copy, Debug)]
51pub struct TurnResult {
52 pub runs: usize,
55 pub immediate_work: bool,
57 pub service_closed: bool,
59 pub sleep_for: Option<Duration>,
61 pub(crate) readiness: crate::policy::WorkReadiness,
62}
63include!("drive_inner.rs");