Lib for work to multiple thread (Node.js)

Related tags

Job Queues ad-worker
Overview

ad-worker

npm i ad-worker

This library allows spawn threads and transfer control by name, with an isolated context, or shared data between threads.

Example

// main.js
const { MainWorker } = require("ad-worker");

const mainWorker = new MainWorker({
    group: [
        { name: "test", path: "./worker.js", workerData: { ok: "ok" }, mutex: 1 },
        { name: "test_2", path: "./worker_2.js", workerDataLink: "test" },
        { name: "test_3", path: "./worker.js", workerDataLink: "test" },
    ],
    sharedData: {
        length: 1024,
        type: "int32"
    }
});
// Or
const mainWorker = new MainWorker({});

mainWorker.newThread({
    name: "test",
    path: "./worker.js",
    sharedData: {
        length: 1024,
        type: "int32"
    },
    workerData: { hello: "world" }
});

mainWorker.newThread({
    name: "test",
    path: "./worker.js"
});

// Or
mainWorker.spawn(()=>{
    console.log("New thread, in this file");
});
// worker.js
const { ChildWorker } = require("ad-worker");
const { workerData } = require("worker_threads");

const childWorker = new ChildWorker(workerData);

childWorker.setSharedData({ hello: "world" });
childWorker.sendMessage("change");
childWorker.lock(()=>{
    childWorker.onMessage(msg => {
        console.log(msg); // Some message
        childWorker.unlock();
    });
});

childWorker.onMessage(msg => {
    console.log(msg);
});
childWorker.sendMessage("ok");

childWorker.close();
// main.js
mainWorker.onMessage("test", msg => {
    if (msg === "change") {
        mainWorker.getSharedData("test", msg => {
            console.log(msg); // {hello: "world"}
        })
        return;
    }
})

mainWorker.getSharedData("test2", msg => {
    console.log(msg); // { ok: "ok" }
})
mainWorker.getSharedData("test", msg => {
    console.log(msg); // { ok: "ok" }
})
You might also like...

Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

Jan 3, 2023

Tüm Discord.js versiyonları için çok hızlı thread integrasyonu 😃

djs-threads 🚀 Tüm Discord.js versiyonları için çok hızlı thread integrasyonu 😃 📚 Örnekler: ✨ Thread oluşturma const Discord = require("discord.js")

Jan 29, 2022

🚀 Blazing fast thread channels integration for all Discord.js versions

djs-threads 🚀 Blazing fast thread integration for all Discord.js versions 😃 THIS PROJECT IS ARCHIVED this project is archived because Discord will c

Feb 28, 2022

Run RPC over a MessagePort object from a Worker thread (or WebWorker)

thread-rpc Run RPC over a MessagePort object from a Worker thread (or WebWorker) npm install thread-rpc Usage First in the parent thread const Thread

May 31, 2022

HN Notifier is a chrome extension that shows the number of unread comments to your HackerNews thread

HN Notifier is a chrome extension that shows the number of unread comments to your HackerNews thread

HN Notifier is a chrome extension that shows the number of unread comments to your HackerNews thread. One of the issues with HackerNews is that it is difficult to know when someone has replied to your post or comment, thus by missing an opporunity to continue the conversation.

Oct 22, 2022

A JavaScript Library To Make Your Work Work Easier/Faster

Functionalty.js (beta) About ✍️ This Is A JavaScript Library To Make Your Work Easier/Faster, You Can See Functionalty.js Website From Here Project Cr

Aug 30, 2022

A JavaScript Library To Make Your Work Work Easier/Faster

Functionality.js (beta) About ✍️ This Is A JavaScript Library To Make Your Work Easier/Faster, You Can See Functionalty.js Website From Here Project C

May 25, 2022

A JavaScript Library To Make Your Work Work Easier/Faster

A JavaScript Library To Make Your Work Work Easier/Faster

Functionality.js About ✍️ This Is A JavaScript Library To Make Your Work Easier/Faster, You Can See Functionalty.js Website From Here Project Created

Jun 23, 2022

eXtensible Template Engine lib for node and the browser

eXtensible Template Engine lib for node and the browser

xtemplate High Speed, eXtensible Template Engine lib on browser and nodejs. support async control, inheritance, include, logic expression, custom func

Nov 21, 2022

Mini Projeto de um chat-app usando o protocolo WebSocket através da lib 'ws' do node.js

Mini Projeto de um chat-app usando o protocolo WebSocket através da lib 'ws' do node.js

CHAT-APP-WEBSOCKET Mini Projeto de um chat-app usando o protocolo WebSocket através da lib 'ws' do node.js Obs o intuito deste projeto não é o fronten

Jul 14, 2022

I'm trying to create simple program for adding the digital signature to a pdf file with self-signed certificate. I use node-signpdf and pdf-lib library.

pdf-digital-signature-with-node-signpdf-ejs I'm trying to create simple program for adding the digital signature to a pdf file with self-signed certif

Dec 25, 2022

Parallel/concurrent async work, optionally using multiple threads or processes

parallel-park Parallel/concurrent async work, optionally using multiple processes Usage parallel-park exports two functions: runJobs and inChildProces

Mar 1, 2022

True P2P concept for your p2p powered website/app/client. MSC/MEP (Multiple Strategy Concept/Multiple Entry Points)

True P2P concept for your p2p powered website/app/client. MSC/MEP (Multiple Strategy Concept/Multiple Entry Points)

TRUE P2P CONCEPT - Lets redecentralize the web This repo is just conceptual. Active development of the endproduct (TRUE P2P) happens here https://gith

Mar 29, 2022

⚡🚀 Call multiple view functions, from multiple Smart Contracts, in a single RPC query!

ethers-multicall ⚡ 🚀 Call multiple view functions, from multiple Smart Contracts, in a single RPC query! Querying an RPC endpoint can be very costly

Dec 30, 2022

:large_orange_diamond: A fantastic mobile ui lib implement by Vue

:large_orange_diamond: A fantastic mobile ui lib implement by Vue

cube-ui A fantastic mobile ui lib implement by Vue. Links Home Docs Example Application Guide Communication New cube-ui project ? Recommend use the CL

Jan 2, 2023

Lightweight WebSocket lib with socket.io-like event handling, requests, and channels

ws-wrapper Lightweight and isomorphic Web Socket lib with socket.io-like event handling, Promise-based requests, and channels. What? Much like Socket.

Dec 23, 2022

Lightweight WebSocketServer wrapper lib using ws-wrapper to wrap connected WebSockets

ws-server-wrapper Lightweight WebSocketServer wrapper lib using ws-wrapper and ws to wrap connected WebSockets. The only dependency is ws-wrapper itse

May 9, 2022

ZippyDamn-lib! is a ZippyShare Unofficial library (downloader & search) for nodejs

ZippyDamn-lib! is a ZippyShare Unofficial library (downloader & search) for nodejs

ZippyDamn-lib! ZippyDamn-lib! is a ZippyShare Unofficial library (downloader & search) for nodejs Looking for a CLI? Try Zippydamn! CLI Installation U

Oct 2, 2021
Releases(v2.0.1)
Owner
Артём Полторацкий
Developer Node.js | Rust
Артём Полторацкий
A simple, fast, robust job/task queue for Node.js, backed by Redis.

A simple, fast, robust job/task queue for Node.js, backed by Redis. Simple: ~1000 LOC, and minimal dependencies. Fast: maximizes throughput by minimiz

Bee Queue 3.1k Jan 5, 2023
A simple high-performance Redis message queue for Node.js.

RedisSMQ - Yet another simple Redis message queue A simple high-performance Redis message queue for Node.js. For more details about RedisSMQ design se

null 501 Dec 30, 2022
Job queues and scheduled jobs for Node.js, Beanstalkd and/or Iron.io.

Ironium Job queues and scheduled jobs for Node.js backed by Beanstalk/IronMQ/SQS. The Why You've got a workload that runs outside the Web app's reques

Assaf Arkin 71 Dec 14, 2022
A fast, robust and extensible distributed task/job queue for Node.js, powered by Redis.

Conveyor MQ A fast, robust and extensible distributed task/job queue for Node.js, powered by Redis. Introduction Conveyor MQ is a general purpose, dis

Conveyor MQ 45 Dec 15, 2022
Bree is the best job scheduler for Node.js and JavaScript with cron, dates, ms, later, and human-friendly support.

The best job scheduler for Node.js and JavaScript with cron, dates, ms, later, and human-friendly support. Works in Node v10+ and browsers, uses workers to spawn sandboxed processes, and supports async/await, retries, throttling, concurrency, and graceful shutdown. Simple, fast, and lightweight. Made for @ForwardEmail and @ladjs.

Bree - The Best Node.js and JavaScript Job Scheduler 2.5k Dec 30, 2022
A simple package for single or batch image download and conversion using node streams.

image-batch-download A simple package for basic image downloading and processing. Supported formats: JPEG PNG WebP Installation With Yarn: yarn add im

Tech Root 777 5 Jan 2, 2022
A simple Node.js APIBAN client for downloading banned IPs and inserting them into a redis set

apiban-redis A simple Node.js APIBAN client for downloading banned IPs and inserting them into a redis set. Installation This utility can be run as a

jambonz 4 Apr 5, 2022
Cache is easy to use data caching Node.js package. It supports Memcached, Redis, and In-Memory caching engines.

Cache Cache NPM implements wrapper over multiple caching engines - Memcached, Redis and In-memory (use with single threaded process in development mod

PLG Works 49 Oct 24, 2022
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022