Expand description
Translation of src/utils/thread_utils.c and src/utils/thread_utils.h from libwebp v1.6.0.
Work package: WP1 (types, memory, workers).
WebPWorkerInterface, WebPSetWorkerInterface and WebPGetWorkerInterface
are not translated (ADR 0003, decided 2026-11-06). Callers use the worker
methods directly, and no public header declares the replacement table.
Every worker starts a std::thread on reset, as the reference configuration
with WEBP_USE_THREAD does. The thread and the caller share one Mutex with
one Condvar. The job (hook and two data values) moves to the thread at
launch and comes back at sync or end; while the worker is working, the
caller has no access to the data, which the borrow checker enforces.
§Deviations from upstream
Changes of representation that the ADRs allow, or behavior that the Rust side cannot reproduce exactly. Each records the reason.
- Worker allocation. The shared synchronization object is allocated in
WebPWorker::init(C:Init) rather than inReset, so a failed allocation cannot makeResetreturnfalse. A failed spawn still does:Resetreturnsfalseand the status staysNOT_OK, as ADR 0003 requires.
Structs§
- WebP
Worker - A worker that runs one hook on its job, on a thread or on the caller’s
thread (C:
WebPWorker). - WebP
Worker Status - State of a worker (C:
WebPWorkerStatus); the values keep the C order.
Type Aliases§
- WebP
Worker Hook - The function a worker runs on its two data values. It returns
falseon error (C:WebPWorkerHook, which returnsint).