jpegxl_rs/
parallel.rs

1/*
2This file is part of jpegxl-rs.
3
4jpegxl-rs is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 3 of the License, or
7(at your option) any later version.
8
9jpegxl-rs is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with jpegxl-rs.  If not, see <https://www.gnu.org/licenses/>.
16*/
17
18//! Parallel runner interface
19//! # Example
20//! ```
21//! #[cfg(feature = "image")]
22//! # || -> Result<(), Box<dyn std::error::Error>> {
23//! use jpegxl_rs::{decoder_builder, parallel::threads_runner::ThreadsRunner};
24//! // Use the default C++ Threads pool runner:
25//! let mut parallel_runner = ThreadsRunner::default();
26//! let mut decoder = decoder_builder().parallel_runner(&parallel_runner).build()?;
27//! # Ok(())
28//! # };
29//! ```
30//!
31
32use std::ffi::c_void;
33
34pub mod resizable_runner;
35pub mod threads_runner;
36
37use jpegxl_sys::threads::parallel_runner::JxlParallelRunner;
38
39pub use jpegxl_sys::threads::parallel_runner::{
40    JxlParallelRetCode, JxlParallelRunFunction, JxlParallelRunInit,
41};
42
43use crate::decode::BasicInfo;
44
45/// JPEG XL Parallel Runner
46#[allow(clippy::module_name_repetitions)]
47pub trait ParallelRunner {
48    /// Get a [`JxlParallelRunner`] for the parallel runner.
49    fn runner(&self) -> JxlParallelRunner;
50
51    /// Get an opaque pointer to the runner.
52    fn as_opaque_ptr(&self) -> *mut c_void;
53
54    /// Callback function after getting basic info
55    #[allow(unused_variables)]
56    fn callback_basic_info(&self, basic_info: &BasicInfo) {}
57}