pub struct AsyncVisualizationPipeline { /* private fields */ }Expand description
Asynchronous preprocessing pipeline for large visualization data updates.
Use this when visualization data preparation (binning, normalisation,
aggregation, coordinate transforms) is too heavy for the main thread’s
per-frame budget. The pipeline offloads work to the same
DataTaskPool used for terrain and vector tessellation.
§Usage
let pool: Arc<dyn rustial_engine::DataTaskPool> = Arc::new(ThreadDataTaskPool::new());
let mut viz_pipeline = AsyncVisualizationPipeline::new(pool);
// Dispatch a heavy computation on a background thread.
viz_pipeline.dispatch(Box::new(|| {
// Expensive data processing...
let values: Vec<f32> = (0..10_000).map(|i| (i as f32).sin()).collect();
VisualizationTaskOutput::ScalarFieldUpdate {
layer_name: "heatmap".to_string(),
values,
}
}));
// Each frame, poll for completed results.
for result in viz_pipeline.poll() {
match result {
VisualizationTaskOutput::ScalarFieldUpdate { layer_name, values } => {
// Apply: state.update_scalar_field(&layer_name, values);
}
_ => {}
}
}Implementations§
Source§impl AsyncVisualizationPipeline
impl AsyncVisualizationPipeline
Sourcepub fn new(pool: Arc<dyn DataTaskPool>) -> Self
pub fn new(pool: Arc<dyn DataTaskPool>) -> Self
Create a new async visualization pipeline backed by the given task pool.
Sourcepub fn dispatch(
&mut self,
task: Box<dyn FnOnce() -> VisualizationTaskOutput + Send + 'static>,
)
pub fn dispatch( &mut self, task: Box<dyn FnOnce() -> VisualizationTaskOutput + Send + 'static>, )
Dispatch a visualization preprocessing task to the background thread pool.
The closure runs on a background thread and should return a
VisualizationTaskOutput with the preprocessed data.
Sourcepub fn poll(&mut self) -> Vec<VisualizationTaskOutput>
pub fn poll(&mut self) -> Vec<VisualizationTaskOutput>
Poll all pending tasks and return completed results.
Call this once per frame from the main thread. Incomplete tasks remain in the pending queue for the next poll.
Sourcepub fn pending_count(&self) -> usize
pub fn pending_count(&self) -> usize
Return the number of tasks currently in-flight.