dope_core/executor/raw/
app.rs1use std::{ops, pin};
2
3use crate::driver::{self, life, schedule, settings};
4
5use crate::executor;
6
7pub trait Layout<'d> {
9 type Scope: driver::route::Selection;
10 type ParkPlan: executor::raw::Plan;
12}
13
14pub unsafe trait App<'d>: Sized + Layout<'d> {
21 const ROUTES: settings::Routes;
22
23 const DISPATCH_ROUTES: settings::Routes = Self::ROUTES;
25
26 const WAKE_ROUTES: settings::Routes = settings::Routes::EMPTY;
28
29 const COORDS: usize = 0;
31
32 const PARK: bool = false;
33
34 fn census(_: pin::Pin<&Self>, counts: &mut executor::raw::Census) -> Option<()> {
35 if Self::PARK {
36 counts.include_leaf(Self::COORDS)?;
37 }
38 Some(())
39 }
40
41 unsafe fn sweep<'app, 'driver, 'turn>(
44 app: pin::Pin<&'app mut Self>,
45 sweep: &mut executor::raw::Sweep<'driver, 'turn, 'd, impl crate::io::Report>,
46 ) where
47 'd: 'driver + 'turn,
48 {
49 if Self::PARK {
50 unsafe { sweep.leaf(app) };
52 }
53 }
54
55 unsafe fn park<'app, 'driver, 'turn>(
59 _: pin::Pin<&'app mut Self>,
60 _: schedule::Turn<'turn, 'd>,
61 _: &'driver mut driver::life::Lifecycle<'d, impl crate::io::Report>,
62 ) where
63 'd: 'driver + 'turn,
64 {
65 }
66
67 fn admit(
69 _: pin::Pin<&Self>,
70 needs: &mut settings::claim::Needs,
71 ) -> Result<(), settings::errors::Claim> {
72 *needs = needs.include(settings::claim::Claim::new(Self::ROUTES))?;
73 Ok(())
74 }
75
76 unsafe fn released(_: pin::Pin<&mut Self>) {}
79
80 fn install(_: pin::Pin<&mut Self>, _: life::Install<'_, 'd>) {}
81
82 unsafe fn activate<'app, 'driver, 'turn>(
89 _: pin::Pin<&'app mut Self>,
90 _: driver::route::Erased<'d, driver::route::kind::Any>,
91 _: schedule::Turn<'turn, 'd>,
92 _: &'driver mut driver::life::Lifecycle<'d, impl crate::io::Report>,
93 ) -> bool
94 where
95 'd: 'driver + 'turn,
96 {
97 false
98 }
99
100 fn has_dispatch_owner(_: pin::Pin<&Self>, route: driver::route::Route) -> bool {
102 Self::DISPATCH_ROUTES.has_route(route)
103 }
104
105 fn dispatch<'event>(
107 _: pin::Pin<&mut Self>,
108 event: executor::raw::Dispatch<'event, 'd, Self::Scope>,
109 _: schedule::Turn<'_, 'd>,
110 _: &mut driver::life::Lifecycle<'d, impl crate::io::Report>,
111 ) -> ops::ControlFlow<executor::raw::Dispatch<'event, 'd, Self::Scope>> {
112 ops::ControlFlow::Break(event)
113 }
114
115 fn progress<const STOP: bool>(
117 _: pin::Pin<&Self>,
118 _: executor::raw::Progress<'_, '_, 'd>,
119 _: Option<&mut schedule::Waits<'d>>,
120 ) -> ops::ControlFlow<()> {
121 ops::ControlFlow::Continue(())
122 }
123
124 fn shutdown(
125 _: pin::Pin<&mut Self>,
126 _: schedule::Turn<'_, 'd>,
127 _: &mut driver::life::Lifecycle<'d, impl crate::io::Report>,
128 ) {
129 }
130
131 fn finish(
132 _: pin::Pin<&mut Self>,
133 _: life::Install<'_, 'd>,
134 _: &mut life::finish::Finish<'_, 'd, impl crate::io::Report>,
135 ) {
136 }
137}
138
139impl<'d> Layout<'d> for () {
140 type Scope = std::convert::Infallible;
141 type ParkPlan = ();
142}
143
144unsafe impl<'d> App<'d> for () {
146 const ROUTES: settings::Routes = settings::Routes::EMPTY;
147}