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
rayonthread pool - A
tokioruntime - 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 + Syncso it can be stored inMapState. - The closure must be
Send + 'staticbecause it will execute on a different thread.
Required Methods§
Sourcefn spawn_terrain(
&self,
task: Box<dyn FnOnce() -> TerrainTaskOutput + Send + 'static>,
) -> Box<dyn DataTaskResultReceiver<TerrainTaskOutput>>
fn spawn_terrain( &self, task: Box<dyn FnOnce() -> TerrainTaskOutput + Send + 'static>, ) -> Box<dyn DataTaskResultReceiver<TerrainTaskOutput>>
Spawn a terrain mesh generation task.
Sourcefn spawn_vector(
&self,
task: Box<dyn FnOnce() -> VectorTaskOutput + Send + 'static>,
) -> Box<dyn DataTaskResultReceiver<VectorTaskOutput>>
fn spawn_vector( &self, task: Box<dyn FnOnce() -> VectorTaskOutput + Send + 'static>, ) -> Box<dyn DataTaskResultReceiver<VectorTaskOutput>>
Spawn a vector tessellation task.
Sourcefn spawn_decode(
&self,
task: Box<dyn FnOnce() -> MvtDecodeOutput + Send + 'static>,
) -> Box<dyn DataTaskResultReceiver<MvtDecodeOutput>>
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.