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, 'root>(
42 app: pin::Pin<&'app mut Self>,
43 plan: &mut Self::ParkPlan,
44 park: executor::raw::Park<'driver, 'turn, 'root, 'd>,
45 ) where
46 'd: 'driver + 'turn + 'root;
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, 'root>(
74 _: pin::Pin<&'app mut Self>,
75 _: executor::raw::Activate<'driver, 'turn, 'root, 'd>,
76 ) -> bool
77 where
78 'd: 'driver + 'turn + 'root,
79 {
80 false
81 }
82
83 fn dispatch<'app, 'driver, 'turn, 'root>(
84 call: executor::raw::Dispatch<'app, 'driver, 'turn, 'root, 'd, Self>,
85 ) -> ops::ControlFlow<io::Event<'d>>
86 where
87 'd: 'root,
88 Self: 'root,
89 {
90 ops::ControlFlow::Break(call.into_event())
91 }
92
93 fn progress(
94 app: pin::Pin<&Self>,
95 view: executor::raw::Progress<'_, '_, 'd>,
96 ) -> schedule::Progress<'d>;
97
98 fn stopping(
99 app: pin::Pin<&Self>,
100 view: executor::raw::Progress<'_, '_, 'd>,
101 ) -> schedule::Progress<'d>;
102
103 fn shutdown<'app, 'turn, 'driver, 'owner>(
104 shutdown: executor::raw::Shutdown<'app, 'turn, 'driver, 'owner, 'd, Self>,
105 ) -> executor::raw::Shutdown<'app, 'turn, 'driver, 'owner, 'd, Self>
106 where
107 'd: 'owner,
108 {
109 shutdown
110 }
111
112 fn finish<'app, 'finish, 'owner, 'epoch>(
113 finish: executor::raw::Finish<'app, 'finish, 'owner, 'epoch, 'd, Self>,
114 ) -> executor::raw::Finish<'app, 'finish, 'owner, 'epoch, 'd, Self> {
115 finish
116 }
117}