Expand description
API for running data operations in parallel in a multi-threaded environment. This module allows the JPEG XL caller to define their own way of creating and assigning threads.
The JxlParallelRunner function type defines a parallel data processing
runner that may be implemented by the caller to allow the library to process
in multiple threads. The multi-threaded processing in this library only
requires to run the same function over each number of a range, possibly
running each call in a different thread. The JPEG XL caller is responsible
for implementing this logic using the thread APIs available in their system.
For convenience, a C++ implementation based on std::thread is provided in
super::thread_parallel_runner (part of the jpegxl_threads library).
Thread pools usually store small numbers of heterogeneous tasks in a queue.
When tasks are identical or differ only by an integer input parameter, it is
much faster to store just one function of an integer parameter and call it
for each value. Conventional vector-of-tasks can be run in parallel using a
lambda function adapter that simply calls task_funcs[task].
If no multi-threading is desired, a NULL value of JxlParallelRunner
will use an internal implementation without multi-threading.
Constants§
- JXL_
PARALLEL_ RET_ RUNNER_ ERROR - Code returned by the
JxlParallelRunInitfunction to indicate a general error. - JXL_
PARALLEL_ RET_ SUCCESS - Code returned by the
JxlParallelRunInitfunction to indicate success.
Type Aliases§
- JxlParallel
RetCode - Return code used in the
JxlParallel*functions as return value. A value ofJXL_PARALLEL_RET_SUCCESSmeans success and any other value means error. The special valueJXL_PARALLEL_RET_RUNNER_ERRORcan be used by the runner to indicate any other error. - JxlParallel
RunFunction - Parallel run data processing callback. See
JxlParallelRunnerfor details. - JxlParallel
RunInit - Parallel run initialization callback. See
JxlParallelRunnerfor details. - JxlParallel
Runner JxlParallelRunnerfunction type. A parallel runner implementation can be provided by a JPEG XL caller to allow running computations in multiple threads. This function must call the initialization functioninitin the same thread that called it and then call the passedfunconce for every number in the range[start_range, end_range)(includingstart_rangebut not includingend_range) possibly from different multiple threads in parallel.