Comparing version 1.0.0-beta.3 to 1.0.0-beta.4
@@ -71,2 +71,3 @@ "use strict"; | ||
: eval("require")("worker_threads").Worker; | ||
let allWorkers = []; | ||
class Worker extends NativeWorker { | ||
@@ -82,2 +83,3 @@ constructor(scriptPath) { | ||
this.mappedEventListeners = new WeakMap(); | ||
allWorkers.push(this); | ||
} | ||
@@ -96,2 +98,9 @@ addEventListener(eventName, rawListener) { | ||
} | ||
const terminateAll = () => { | ||
allWorkers.forEach(worker => worker.terminate()); | ||
allWorkers = []; | ||
}; | ||
// Take care to not leave orphaned processes behind. See #147. | ||
process.on("SIGINT", () => terminateAll()); | ||
process.on("SIGTERM", () => terminateAll()); | ||
return Worker; | ||
@@ -98,0 +107,0 @@ } |
@@ -161,3 +161,3 @@ "use strict"; | ||
} | ||
if (typeof process !== "undefined" && implementation_1.default.isWorkerRuntime()) { | ||
if (typeof process !== "undefined" && typeof process.on === "function" && implementation_1.default.isWorkerRuntime()) { | ||
process.on("uncaughtException", (error) => { | ||
@@ -164,0 +164,0 @@ // Post with some delay, so the master had some time to subscribe to messages |
{ | ||
"name": "threads", | ||
"version": "1.0.0-beta.3", | ||
"version": "1.0.0-beta.4", | ||
"description": "Easy to use, yet powerful multi-threading library for node.js, web browsers and Electron", | ||
@@ -25,3 +25,3 @@ "main": "dist/index.js", | ||
}, | ||
"homepage": "https://github.com/andywer/threads.js#readme", | ||
"homepage": "https://threads.js.org", | ||
"keywords": [ | ||
@@ -28,0 +28,0 @@ "thread", |
@@ -14,6 +14,6 @@ <h1 align="center">threads</h1> | ||
* **Speed up** code by parallel processing | ||
* **Keep UI responsive** by offloading work from rendering thread | ||
* First-class support for **async functions** & **observables** | ||
* Manage bulk task executions with **thread pools** | ||
* Works great with **webpack** | ||
* Allows using **require()** and **import**/**export** in workers | ||
@@ -20,0 +20,0 @@ ### Version 0.x |
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
82213
1782