use std::pin;
use crate::{Errno, driver::schedule::clock::Sample};
use crate::{
executor::{
self,
drive::clock,
session::{self, run},
},
topology::lending,
};
impl<'life, 'd: 'life, Q: 'life, Report: crate::io::Report> session::Core<'life, 'd, Q, Report> {
pub(crate) fn execute<H, T, R, C>(
&mut self,
head: H,
app: T,
start: Sample,
run: impl for<'app> FnOnce(&mut run::Run<'app, 'life, 'd, H::Joined<T>, Q, Report>) -> (R, C),
) -> (H::Retired, run::Outcome<R, C, Q::Error>, Option<Errno>)
where
H: lending::raw::Head<'d>,
T: executor::raw::App<'d>,
C: clock::Time,
Q: executor::Startup,
{
let backing = pin::pin!(executor::raw::Backing::new(
self.scope.token(),
head.join(app)
));
let mut scope = run::Run::install(self, start, backing.as_ref());
if let Err(error) = scope.admit() {
let (head, disarm) = scope.cancel_child::<H, T>();
return (head, Err(error), disarm);
}
let (output, source) = run(&mut scope);
let (head, result, disarm) = scope.finish_child::<H, T, C>(source);
(head, Ok((output, source, result)), disarm)
}
}