dope_runtime/executor/raw/
app.rs1use std::{ops, pin};
2
3use dope_core::{
4 driver::{schedule, settings},
5 io,
6};
7
8use crate::executor;
9
10pub trait Layout<'d> {
12 type ParkPlan;
14}
15
16pub unsafe trait App<'d>: Sized + Layout<'d> {
21 const ROUTES: settings::Routes;
22
23 const WAKE_ROUTES: settings::Routes = settings::Routes::EMPTY;
25
26 const COORDS: usize;
28
29 fn select_park() -> Option<Self::ParkPlan>;
30
31 fn prepare_park(_: pin::Pin<&Self>, _: &mut Self::ParkPlan) -> Option<executor::raw::Count> {
35 Some(executor::raw::Count::new(Self::COORDS))
36 }
37
38 unsafe fn park<'app, 'driver, 'turn>(
42 app: pin::Pin<&'app mut Self>,
43 plan: &mut Self::ParkPlan,
44 park: executor::raw::Park<'driver, 'turn, 'd>,
45 ) where
46 'd: 'driver + 'turn;
47
48 fn admit(
50 _: pin::Pin<&Self>,
51 needs: &mut settings::claim::Needs,
52 ) -> Result<(), settings::errors::Claim> {
53 *needs = needs.include(settings::claim::Claim::new(Self::ROUTES))?;
54 Ok(())
55 }
56
57 fn released(released: executor::raw::Released<'_, Self>) -> executor::raw::Released<'_, Self> {
58 released
59 }
60
61 fn install<'app, 'owner>(
62 install: executor::raw::Install<'app, 'owner, 'd, Self>,
63 ) -> executor::raw::Install<'app, 'owner, 'd, Self> {
64 install
65 }
66
67 unsafe fn activate<'app, 'driver, 'turn>(
74 _: pin::Pin<&'app mut Self>,
75 _: executor::raw::Activate<'driver, 'turn, 'd>,
76 ) -> bool
77 where
78 'd: 'driver + 'turn,
79 {
80 false
81 }
82
83 fn dispatch<'app, 'driver, 'turn>(
84 call: executor::raw::Dispatch<'app, 'driver, 'turn, 'd, Self>,
85 ) -> ops::ControlFlow<io::Event<'d>> {
86 ops::ControlFlow::Break(call.into_event())
87 }
88
89 fn progress(
90 app: pin::Pin<&Self>,
91 view: executor::raw::Progress<'_, '_, 'd>,
92 ) -> schedule::Progress<'d>;
93
94 fn stopping(
95 app: pin::Pin<&Self>,
96 view: executor::raw::Progress<'_, '_, 'd>,
97 ) -> schedule::Progress<'d>;
98
99 fn shutdown<'app, 'turn, 'driver>(
100 shutdown: executor::raw::Shutdown<'app, 'turn, 'driver, 'd, Self>,
101 ) -> executor::raw::Shutdown<'app, 'turn, 'driver, 'd, Self> {
102 shutdown
103 }
104
105 fn finish<'app, 'finish, 'owner, 'epoch>(
106 finish: executor::raw::Finish<'app, 'finish, 'owner, 'epoch, 'd, Self>,
107 ) -> executor::raw::Finish<'app, 'finish, 'owner, 'epoch, 'd, Self> {
108 finish
109 }
110}