Skip to main content

DataTaskPool

Trait DataTaskPool 

Source
pub trait DataTaskPool: Send + Sync {
    // Required methods
    fn spawn_terrain(
        &self,
        task: Box<dyn FnOnce() -> TerrainTaskOutput + Send + 'static>,
    ) -> Box<dyn DataTaskResultReceiver<TerrainTaskOutput>>;
    fn spawn_vector(
        &self,
        task: Box<dyn FnOnce() -> VectorTaskOutput + Send + 'static>,
    ) -> Box<dyn DataTaskResultReceiver<VectorTaskOutput>>;
    fn spawn_decode(
        &self,
        task: Box<dyn FnOnce() -> MvtDecodeOutput + Send + 'static>,
    ) -> Box<dyn DataTaskResultReceiver<MvtDecodeOutput>>;
}
Expand description

An executor-agnostic task pool for offloading heavy data pipeline work.

The engine submits work items and polls result channels without depending on a specific async runtime. Implementations may use:

  • Bevy’s AsyncComputeTaskPool
  • A rayon thread pool
  • A tokio runtime
  • A simple std::thread-based pool

§Contract

  • Spawn methods must not block. They should enqueue the closure for execution on a background thread and return a receiver immediately.
  • The returned receiver must be Send + Sync so it can be stored in MapState.
  • The closure must be Send + 'static because it will execute on a different thread.

Required Methods§

Source

fn spawn_terrain( &self, task: Box<dyn FnOnce() -> TerrainTaskOutput + Send + 'static>, ) -> Box<dyn DataTaskResultReceiver<TerrainTaskOutput>>

Spawn a terrain mesh generation task.

Source

fn spawn_vector( &self, task: Box<dyn FnOnce() -> VectorTaskOutput + Send + 'static>, ) -> Box<dyn DataTaskResultReceiver<VectorTaskOutput>>

Spawn a vector tessellation task.

Source

fn spawn_decode( &self, task: Box<dyn FnOnce() -> MvtDecodeOutput + Send + 'static>, ) -> Box<dyn DataTaskResultReceiver<MvtDecodeOutput>>

Spawn an MVT decode task.

The closure decodes raw PBF bytes into a [VectorTileData] on a background thread, matching MapLibre’s web worker model.

Implementors§