1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
use std::{ops::ControlFlow, task, time};
use crate::{
Budget,
io::reactor::ready::{
Backend, Driver,
delivery::Decoded,
store::{Exec, Quota},
},
};
pub trait Decode: Exec {
/// # Safety
/// The value was returned by this driver's registered kernel queue.
unsafe fn decode(raw: usize) -> Decoded<Self::Key>;
const SHUTDOWN: Self::Event;
}
pub trait Poll<C: Driver>: Backend<C> {
/// A blocked receive consumes its admission and ends this pass without being removed.
///
/// # Safety
/// Registered operations retain their submitted storage and admitted layouts.
unsafe fn resume<'a>(
&'a mut self,
budget: &mut impl Budget,
) -> Result<ControlFlow<()>, Self::Failure>
where
C::Context: 'a;
/// # Safety
/// Registered operations retain their submitted storage and admitted layouts.
/// Kernel identities belong to this driver's live or retired flights.
unsafe fn wait<'a>(
&'a mut self,
timeout: Option<time::Duration>,
changes: &mut impl Budget,
done: &mut impl Budget,
) -> Result<(), Self::Failure>
where
C::Context: 'a;
}
pub trait Work<C: Driver, Q: Quota>: Sized {
type Backend: Poll<C>;
/// # Safety
/// Registered operations retain their submitted storage and admitted layouts.
unsafe fn new<'a>(backend: &'a mut Self::Backend, quota: Q) -> Self
where
C::Context: 'a;
/// # Safety
/// Registered storage and kernel identities remain valid for this driver's flights.
unsafe fn commit<'a>(
self,
backend: &'a mut Self::Backend,
dirty: bool,
) -> Result<task::Poll<()>, <Self::Backend as Backend<C>>::Failure>
where
C::Context: 'a;
/// # Safety
/// Registered storage and kernel identities remain valid for this driver's flights.
unsafe fn wait<'a>(
self,
backend: &'a mut Self::Backend,
span: Option<time::Duration>,
busy: bool,
) -> Result<(), <Self::Backend as Backend<C>>::Failure>
where
C::Context: 'a;
}