dope_runtime/executor/boot/
context.rs1use std::mem;
2
3use dope_core::driver::schedule::{app, clock, ready};
4
5use crate::executor::{boot, root};
6
7pub struct Context<'poll, 'd: 'poll> {
10 wake: ready::Target<'d>,
11 work: app::Work<'poll, 'd>,
12 cause: boot::Cause,
13}
14
15impl<'poll, 'd: 'poll> Context<'poll, 'd> {
16 pub(crate) fn new(
17 wake: ready::Target<'d>,
18 work: app::Work<'poll, 'd>,
19 cause: boot::Cause,
20 ) -> Self {
21 Self { wake, work, cause }
22 }
23
24 pub fn into_parts(
25 self,
26 ) -> (
27 ready::Target<'d>,
28 app::Work<'poll, 'd>,
29 clock::Clock<'poll, 'd>,
30 boot::Cause,
31 ) {
32 (self.wake, self.work, self.work.clock(), self.cause)
33 }
34
35 pub fn into_poll(self) -> (root::Budget<'poll, 'd>, clock::Clock<'poll, 'd>) {
36 (root::Budget::new(self.wake, self.work), self.work.clock())
37 }
38}
39
40const fn assert_layout() {
41 assert!(mem::size_of::<Context<'static, 'static>>() == 4 * mem::size_of::<usize>());
42 assert!(mem::align_of::<Context<'static, 'static>>() == mem::align_of::<usize>());
43}
44
45const _: () = assert_layout();