use super::{generic::PlanBuilder, FixedPointResidentPlan};
use crate::fixed_point_graph::FixedPointForwardGraph;
use crate::fixed_point_resident::FixedPointResidentGraph;
use crate::fixed_point_resident_frontier::FixedPointResidentFrontierScratch;
impl FixedPointResidentPlan {
pub fn new(
backend: &dyn vyre::VyreBackend,
graph: &FixedPointForwardGraph,
pipeline: std::sync::Arc<dyn vyre::CompiledPipeline>,
) -> Result<Self, vyre::BackendError> {
Ok(Self {
inner: PlanBuilder {
graph: FixedPointResidentGraph::upload(backend, graph)?,
pipeline,
},
})
}
pub fn free_with_frontier(
self,
backend: &dyn vyre::VyreBackend,
resident_frontier: &mut FixedPointResidentFrontierScratch,
) -> Result<(), vyre::BackendError> {
let frontier_result = resident_frontier.clear(backend);
let graph_result = self.inner.graph.free(backend);
match (frontier_result, graph_result) {
(Err(error), _) | (_, Err(error)) => Err(error),
(Ok(()), Ok(())) => Ok(()),
}
}
pub fn free(self, backend: &dyn vyre::VyreBackend) -> Result<(), vyre::BackendError> {
self.inner.graph.free(backend)
}
}