![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
node-worker-pool
Advanced tools
node-worker-pool is a library for managing a pool of child workers in node.
node-worker-pool is a library for managing a pool of child workers in node.
It's primarily useful for scenarios where you have lots of highly parallelizable tasks you want to perform. It works exclusively via message-passing, so there is no need to share memory.
Specifically, node-worker-pool allows you to define your own worker executable that is capable of communicating over stdin/stdout (via a fairly simple protocol for which I have yet to propertly document :p).
You technically don't have to write this file in node, but for the time being there are only node helper libraries for abstracting away the communciation protocols. Here is an example worker:
worker.js
var workerUtils = require('node-worker-pool/nodeWorkerUtils');
/**
* Executed once when the worker pool first starts
* (before any messages are received)
*/
var initData;
function onInitialize(data) {
initData = data;
}
/**
* Executed each time a message is received from the worker pool.
* Returns the response to the message (response must always be an object)
*/
function onMessage(data) {
return {
initData: initData,
receivedData: data
};
}
if (require.main === module) {
try {
workerUtils.startWorker(onInitialize, onMessage);
} catch (e) {
workerUtils.respondWithError(e);
}
}
workerPool.js
if (require.main === module) {
var workerPool = new WorkerPool(
8, // number of workers
process.execPath, // path to the node binary
'./worker.js', // path to the worker script
{
// The initData object that is passed to each worker exactly once before
// any messages get sent. Workers receive this object via their
// onInitialize callback.
initData: {someUsefulConstant: 42}
}
);
workerPool.sendMessage({message: 'hai!'}).then(function(response) {
console.log(response); // Prints the response object from the worker
});
workerPool.shutDown().then(function() {
console.log('All worker processes have now been killed');
});
}
FAQs
node-worker-pool is a library for managing a pool of child workers in node.
The npm package node-worker-pool receives a total of 616 weekly downloads. As such, node-worker-pool popularity was classified as not popular.
We found that node-worker-pool demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.