gatsby-worker
Advanced tools
Comparing version 1.10.0 to 1.10.1
@@ -86,2 +86,3 @@ "use strict"; | ||
process.on(`message`, messageHandler); | ||
ensuredSendToMain([_types.WORKER_READY]); | ||
} |
@@ -106,5 +106,9 @@ "use strict"; | ||
}); | ||
let workerReadyResolve; | ||
const workerInfo = { | ||
workerId, | ||
worker, | ||
ready: new Promise(resolve => { | ||
workerReadyResolve = resolve; | ||
}), | ||
exitedPromise: new Promise(resolve => { | ||
@@ -167,2 +171,4 @@ worker.on(`exit`, (code, signal) => { | ||
} | ||
} else if (msg[0] === _types.WORKER_READY) { | ||
workerReadyResolve(); | ||
} | ||
@@ -238,6 +244,7 @@ }); | ||
doWork(taskInfo, workerInfo) { | ||
async doWork(taskInfo, workerInfo) { | ||
// block worker | ||
workerInfo.currentTask = taskInfo; | ||
this.idleWorkers.delete(workerInfo); | ||
await workerInfo.ready; | ||
const msg = [_types.EXECUTE, taskInfo.functionName, taskInfo.args]; | ||
@@ -244,0 +251,0 @@ workerInfo.worker.send(msg); |
@@ -6,2 +6,3 @@ export declare const EXECUTE = 1; | ||
export declare const CUSTOM_MESSAGE = 4; | ||
export declare const WORKER_READY = 8; | ||
declare type CustomMessage = [typeof CUSTOM_MESSAGE, unknown]; | ||
@@ -12,2 +13,3 @@ declare type FunctionName = string | number | symbol; | ||
declare type EndMessage = [typeof END]; | ||
declare type WorkerReadyMessage = [typeof WORKER_READY]; | ||
export declare type ParentMessageUnion = ExecuteMessage | EndMessage | CustomMessage; | ||
@@ -26,3 +28,3 @@ declare type ErrorType = string; | ||
declare type TaskResult = [typeof RESULT, ResultType]; | ||
export declare type ChildMessageUnion = TaskError | TaskResult | CustomMessage; | ||
export declare type ChildMessageUnion = TaskError | TaskResult | CustomMessage | WorkerReadyMessage; | ||
export {}; |
"use strict"; | ||
exports.__esModule = true; | ||
exports.CUSTOM_MESSAGE = exports.END = exports.RESULT = exports.ERROR = exports.EXECUTE = void 0; | ||
exports.WORKER_READY = exports.CUSTOM_MESSAGE = exports.END = exports.RESULT = exports.ERROR = exports.EXECUTE = void 0; | ||
const EXECUTE = 0b01; | ||
@@ -14,2 +14,4 @@ exports.EXECUTE = EXECUTE; | ||
const CUSTOM_MESSAGE = 0b100; | ||
exports.CUSTOM_MESSAGE = CUSTOM_MESSAGE; | ||
exports.CUSTOM_MESSAGE = CUSTOM_MESSAGE; | ||
const WORKER_READY = 0b1000; | ||
exports.WORKER_READY = WORKER_READY; |
{ | ||
"name": "gatsby-worker", | ||
"description": "Utility to create worker pools", | ||
"version": "1.10.0", | ||
"version": "1.10.1", | ||
"author": "Michal Piechowiak<misiek.piechowiak@gmail.com>", | ||
@@ -42,3 +42,3 @@ "bugs": { | ||
}, | ||
"gitHead": "24b9fde1c7705e27e5d7b24c7ef53189609f4f04" | ||
"gitHead": "7c43f38b344ec94bba4f96311339c76f18874b65" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
35970
532