Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Elyahou authored and jasnell committed May 2, 2022
1 parent 52be44d commit bb37c26
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion examples/messages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const piscina = new Piscina({

(async function () {
piscina.on('message', (event) => {
console.log("Messsage received from worker: ", event);
console.log('Messsage received from worker: ', event);
});

await piscina.run();
Expand Down
4 changes: 2 additions & 2 deletions examples/messages/worker.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';
const { parentPort } = require('worker_threads')
const { parentPort } = require('worker_threads');

module.exports = () => {
parentPort.postMessage('hello from the worker pool');
parentPort.postMessage('hello from the worker pool');
};
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ class ThreadPool {
pool._processPendingMessages();
}

function onReady() {
function onReady () {
if (workerInfo.currentUsage() === 0) {
workerInfo.unref();
}
Expand All @@ -626,7 +626,7 @@ class ThreadPool {
}
}

function onEventMessage(message: any) {
function onEventMessage (message: any) {
pool.publicInterface.emit('message', message);
}

Expand Down
16 changes: 8 additions & 8 deletions test/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ import { resolve } from 'path';
import { once } from 'events';

test('Pool receive message from workers', async ({ equal }) => {
const pool = new Piscina({
filename: resolve(__dirname, 'fixtures/eval.js')
});
const pool = new Piscina({
filename: resolve(__dirname, 'fixtures/eval.js')
});

const messagePromise = once(pool, 'message');
const messagePromise = once(pool, 'message');

const taskResult = pool.runTask(`
const taskResult = pool.runTask(`
require('worker_threads').parentPort.postMessage("some message");
42
`);
equal(await taskResult, 42);
equal((await messagePromise)[0], 'some message');
});
equal(await taskResult, 42);
equal((await messagePromise)[0], 'some message');
});

0 comments on commit bb37c26

Please sign in to comment.