Skip to content

components/worker-pool-component

A component that owns several workers built from the same bundled source and spreads calls over them.

Class Description
WorkerPoolComponent Owns a fixed number of WorkerComponent children and sends each call to the one with the fewest pending calls. Use it for CPU-bound jobs that split into independent calls. A job that keeps state in a worker (a loaded corpus, an instantiated module) addresses each worker by index through WorkerPoolComponent.getWorker instead.
Interface Description
WorkerPoolComponentConstructorParams Parameters of WorkerPoolComponent.
Function Description
getDefaultWorkerPoolSize Suggests a pool size: one fewer than the logical processors, so the main thread keeps one, between 1 and MAX_DEFAULT_WORKER_POOL_SIZE.
Type Description
WorkerPoolComponentCallOptions Options of WorkerPoolComponent.call: the same as WorkerComponent.call’s.
Variable Description
MAX_DEFAULT_WORKER_POOL_SIZE The most workers getDefaultWorkerPoolSize suggests, so a pool on a many-core desktop does not starve Obsidian’s own renderer of memory.