Rework fallback for postMessage issue

Now initialise all workers with module+memory separately, and then instead of using postMessage to send thread pointers, push them into a crossbeam-deque on the Rust side.

Rayon already depends on crossbeam-dequeue, so we're not even adding another dependency, and this model allows us to push "tasks" (thread pointers) on the main thread and pop them on worker threads in arbitrary order without sacrificing correctness.
This commit is contained in:
Ingvar Stepanyan
2020-04-27 23:18:42 +01:00
committed by Ingvar Stepanyan
parent 4c658b79ef
commit 0747d2c419
12 changed files with 253 additions and 255 deletions

View File

@@ -1,7 +1,7 @@
// @ts-ignore
import { optimise } from '../../../codecs/oxipng/spawn.js';
import optimiser from '../../../codecs/oxipng/spawn.js';
import { EncodeOptions } from './encoder-meta';
export async function compress(data: ArrayBuffer, options: EncodeOptions): Promise<ArrayBuffer> {
return (await optimise(new Uint8Array(data), options.level)).buffer;
return (await optimiser).optimise(new Uint8Array(data), options.level).buffer;
}