mln-rs-runtime 0.0.23

Part of mln-rs, a MapLibre map renderer written in Rust. Depend on mln-rs instead.
Documentation
//! Settings for the test tools (`tools/render-test`) that no host has a use
//! for. Built only with the `testing` feature, and hidden from the
//! documentation: they aren't API.

use std::sync::atomic::Ordering;

use crate::Runtime;

/// Puts the tile workers of the renderers that `runtime`'s render sessions
/// make from now on in `instances` worker instances, which the renderer
/// reaches only through the worker codec, as the browser build's Web
/// Workers are: every job, bucket and tile crosses as bytes. 0 runs them on
/// the runtime's pool again. A session that is attached keeps its workers.
pub fn set_tile_worker_codec(runtime: &Runtime, instances: usize) {
    runtime.shared.tile_worker_instances.store(instances, Ordering::SeqCst);
}

/// Holds `map`'s frame clock at `time`, once the map exists: the map takes
/// it for the time now, and frames sample its animations and fades at it,
/// until the next hold moves it. A frame demanded next shows the map's
/// last update, which a camera animation's sample or a requested repaint
/// (`Map::request_repaint`) makes at the new time.
pub fn hold_frame_clock(map: &crate::Map, time: mln_style::time::Instant) {
    map.hold_frame_clock(time);
}

/// Starts a runtime as [`Runtime::with_registry`] does, whose maps load
/// through `file_source` instead of the runtime's own loader, and whose
/// background work, its maps' and their render sessions', runs on `pool`,
/// such as a pool without threads that a test runs between frames.
pub fn runtime(
    registry: std::sync::Arc<mln_engine::Registry>,
    pool: mln_engine::exec::pool::Pool,
    file_source: std::sync::Arc<dyn mln_engine::storage::FileSource>,
) -> Result<Runtime, mln_style::error::Error> {
    Runtime::with_parts(&crate::RuntimeOptions::default(), registry, pool, Some(file_source))
}