pub struct Scheduler { /* private fields */ }Expand description
A demand-driven, parallel tile evaluator.
One scheduler can run many pipelines; the pool and cache are reused.
Implementations§
Source§impl Scheduler
impl Scheduler
Sourcepub fn new(options: SchedulerOptions) -> Result<Scheduler, PixelsError>
pub fn new(options: SchedulerOptions) -> Result<Scheduler, PixelsError>
Build a scheduler with options.
§Errors
Returns PixelsError::Io if worker threads cannot be spawned.
Sourcepub fn with_defaults() -> Result<Scheduler, PixelsError>
pub fn with_defaults() -> Result<Scheduler, PixelsError>
Sourcepub fn global() -> Result<Arc<Scheduler>, PixelsError>
pub fn global() -> Result<Arc<Scheduler>, PixelsError>
The process-wide scheduler, built on first use with default options: one worker per core and the default cache budget.
This is what an output runs on unless told otherwise, so every pipeline in a process shares one pool of threads and one tile cache however many run at once. Concurrent runs queue their tiles on the same workers rather than each spawning a pool of their own, which is what keeps a server handling forty requests at a time from running forty threads per core. Its workers sleep while there is no work and live as long as the process.
§Errors
Returns PixelsError::Io if the first call cannot spawn the worker
threads. A later call tries again.
Sourcepub fn run(
&self,
image: &Image,
consume: impl FnMut(Region, &Tile<'_>) -> Result<(), PixelsError>,
) -> Result<RunStats, PixelsError>
pub fn run( &self, image: &Image, consume: impl FnMut(Region, &Tile<'_>) -> Result<(), PixelsError>, ) -> Result<RunStats, PixelsError>
Evaluate image, handing each output tile to consume in order.
consume is called on the calling thread, in tile order, so a sink may
hold non-Send state and an encoder still sees rows top to bottom.
§Errors
Propagates any producer, op or consumer error. A failure anywhere fails the whole run; the sink is simply not given the remaining tiles (ARCHITECTURE §Failure model).