Skip to main content

dope_sys/engine/
raw.rs

1use std::time;
2
3use o3::mem::quota;
4
5use crate::engine::{Buffer, Source, life, register};
6
7type Created<S, C, G> = (
8    <S as Source<C>>::Backend,
9    <<S as Source<C>>::Backend as Buffer>::Context,
10    <S as Create<C, G>>::Receive,
11);
12
13/// Arms a shutdown source owned outside the native engine.
14pub trait Register {
15    /// # Safety
16    /// Retain the source's exact descriptor until engine quiescence or destruction,
17    /// including when a submission is published before this method returns an error.
18    unsafe fn register(&mut self, source: register::Source<'_>) -> Result<(), register::Error>;
19}
20
21/// Finishes native retirement and rearms the retained generation source.
22pub trait Resume<'a, R>
23where
24    R: life::Resume + 'a,
25    <R::Backend as Poll>::Context: 'a,
26{
27    /// # Safety
28    /// Retain the exact source descriptor continuously until the next native
29    /// quiescence or destruction, including when rearming publishes before an error.
30    unsafe fn try_resume(resolver: R) -> life::Retirement<R, R>;
31}
32
33/// Commits and waits while the host retains the registered operation owners.
34pub trait Poll {
35    type Context;
36    type Error: Copy + Eq;
37
38    /// # Safety
39    /// Registered storage and kernel identities remain valid for this driver's flights.
40    unsafe fn wait<'a, Tag>(
41        &'a mut self,
42        quota: quota::Shared<'_, Tag>,
43        timeout: Option<time::Duration>,
44        busy: bool,
45    ) -> Result<(), Self::Error>
46    where
47        Self::Context: 'a;
48}
49
50/// Creates the native runtime and its external receive owners in backend order.
51pub trait Create<C, G>: Source<C>
52where
53    Self::Backend: Buffer,
54{
55    type Receive;
56    type Error;
57
58    /// # Safety
59    /// Retain the returned buffer context alongside the backend until native
60    /// quiescence and destruction, including every returned partial cleanup owner.
61    unsafe fn try_new(config: &G) -> Result<Created<Self, C, G>, Self::Error>;
62}