Skip to main content

AsyncVisualizationPipeline

Struct AsyncVisualizationPipeline 

Source
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

Source

pub fn new(pool: Arc<dyn DataTaskPool>) -> Self

Create a new async visualization pipeline backed by the given task pool.

Source

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.

Source

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.

Source

pub fn pending_count(&self) -> usize

Return the number of tasks currently in-flight.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.