Loading...
Searching...
No Matches
parallel_runner.h
Go to the documentation of this file.
/* Copyright (c) the JPEG XL Project Authors. All rights reserved.
*
* Use of this source code is governed by a BSD-style
* license that can be found in the LICENSE file.
*/
#ifndef JXL_PARALLEL_RUNNER_H_
#define JXL_PARALLEL_RUNNER_H_
#include <stddef.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef int JxlParallelRetCode;
#define JXL_PARALLEL_RET_SUCCESS (0)
#define JXL_PARALLEL_RET_RUNNER_ERROR (-1)
typedef JxlParallelRetCode (*JxlParallelRunInit)(void* jpegxl_opaque,
size_t num_threads);
typedef void (*JxlParallelRunFunction)(void* jpegxl_opaque, uint32_t value,
size_t thread_id);
typedef JxlParallelRetCode (*JxlParallelRunner)(
void* runner_opaque, void* jpegxl_opaque, JxlParallelRunInit init,
JxlParallelRunFunction func, uint32_t start_range, uint32_t end_range);
/* The following is an example of a @ref JxlParallelRunner that doesn't use any
* multi-threading. Note that this implementation doesn't store any state
* between multiple calls of the ExampleSequentialRunner function, so the
* runner_opaque value is not used.
JxlParallelRetCode ExampleSequentialRunner(void* runner_opaque,
void* jpegxl_opaque,
JxlParallelRunInit init,
JxlParallelRunFunction func,
uint32_t start_range,
uint32_t end_range) {
// We only use one thread (the currently running thread).
JxlParallelRetCode init_ret = (*init)(jpegxl_opaque, 1);
if (init_ret != 0) return init_ret;
// In case of other initialization error (for example when initializing the
// threads) one can return JXL_PARALLEL_RET_RUNNER_ERROR.
for (uint32_t i = start_range; i < end_range; i++) {
// Every call is in the thread number 0. These don't need to be in any
// order.
(*func)(jpegxl_opaque, i, 0);
}
return JXL_PARALLEL_RET_SUCCESS;
}
*/
#ifdef __cplusplus
}
#endif
#endif /* JXL_PARALLEL_RUNNER_H_ */
JxlParallelRunner
JxlParallelRetCode(* JxlParallelRunner)(void *runner_opaque, void *jpegxl_opaque, JxlParallelRunInit init, JxlParallelRunFunction func, uint32_t start_range, uint32_t end_range)
Definition parallel_runner.h:127
JxlParallelRunInit
JxlParallelRetCode(* JxlParallelRunInit)(void *jpegxl_opaque, size_t num_threads)
Definition parallel_runner.h:83
JxlParallelRetCode
int JxlParallelRetCode
Definition parallel_runner.h:52
JxlParallelRunFunction
void(* JxlParallelRunFunction)(void *jpegxl_opaque, uint32_t value, size_t thread_id)
Definition parallel_runner.h:102