dope_core/executor/raw/
mod.rs1use std::{num::NonZero, ops::ControlFlow, pin};
4
5use crate::driver::{self, schedule};
6use o3::base::{cell::region, num::bounded::U32};
7
8use crate::executor;
9
10mod app;
11mod owner;
12mod plan;
13mod progress;
14
15pub use crate::io::event::{Dispatch, Occupied};
16pub use app::{App, Layout};
17pub(crate) use owner::{Backing, Draining, Live, Owner, View};
18pub use plan::{Census, Flat, Plan, Sweep};
19pub use progress::Progress;
20
21pub unsafe trait Drain<'d>: executor::raw::App<'d> {
29 fn begin(
30 self: pin::Pin<&mut Self>,
31 turn: schedule::Turn<'_, 'd>,
32 driver: &mut driver::life::Lifecycle<'d, impl crate::io::Report>,
33 );
34
35 fn progress(
41 self: pin::Pin<&Self>,
42 region: ®ion::Token<region::Identity<'d>>,
43 state: Option<&mut schedule::Waits<'d>>,
44 ) -> ControlFlow<()>;
45
46 fn force(
47 self: pin::Pin<&mut Self>,
48 turn: schedule::Turn<'_, 'd>,
49 driver: &mut driver::life::Lifecycle<'d, impl crate::io::Report>,
50 );
51}
52
53#[derive(Clone, Copy, Debug)]
55pub enum Count {
56 Bounded(U32<0, { schedule::LIMIT as u32 }>),
57 Excess(NonZero<usize>),
58}
59
60impl Count {
61 pub const fn new(value: usize) -> Self {
62 match U32::from_usize(value) {
63 Some(value) => Self::Bounded(value),
64 None => Self::Excess(NonZero::<usize>::MIN.saturating_add(value - 1)),
65 }
66 }
67
68 pub const fn get(self) -> usize {
69 match self {
70 Self::Bounded(value) => value.into_usize(),
71 Self::Excess(value) => value.get(),
72 }
73 }
74
75 pub(in crate::executor::raw) fn admit<E>(self) -> Result<(), executor::InstallError<E>> {
76 match self {
77 Self::Bounded(_) => Ok(()),
78 Self::Excess(count) => Err(executor::InstallError::Coordinators {
79 count,
80 limit: schedule::LIMIT,
81 }),
82 }
83 }
84}