Skip to content

Commit

Permalink
Merge branch 'master' into async-decodeBlock
Browse files Browse the repository at this point in the history
  • Loading branch information
manzt committed Sep 10, 2020
2 parents 1cee7a3 + 6b83f8a commit a07d855
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/decoder.worker.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { expose } from 'threads/worker';
import { expose, Transfer } from 'threads/worker';
import { getDecoder } from './compression';

function decode(fileDirectory, buffer) {
const decoder = getDecoder(fileDirectory);
return decoder.decode(fileDirectory, buffer);
return Transfer(decoder.decode(fileDirectory, buffer));
}

expose(decode);
4 changes: 2 additions & 2 deletions src/pool.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Pool as tPool, spawn, Worker } from 'threads';
import { Pool as tPool, spawn, Worker, Transfer } from 'threads';

const defaultPoolSize = typeof navigator !== 'undefined' ? navigator.hardwareConcurrency : null;

Expand Down Expand Up @@ -30,7 +30,7 @@ class Pool {
return new Promise((resolve, reject) => {
this.pool.queue(async (decode) => {
try {
const data = await decode(fileDirectory, buffer);
const data = await decode(fileDirectory, Transfer(buffer));
resolve(data);
} catch (err) {
reject(err);
Expand Down

0 comments on commit a07d855

Please sign in to comment.