Lightweight concurrency and parallelism toolkit for Node.js built on worker_threads.
- Primitives:
Mutex,RwLock,CountingSemaphore,BinarySemaphore,WorkerPool - Data structures:
ConcurrentQueue,ConcurrentPriorityQueue,ConcurrentDeque,ConcurrentStack,ConcurrentSet - Methods:
parallelPipeline(...),parallelQuickSort(...)and quick-sort utilities - Task scheduler:
Scheduler
npm install dahlia-concurrencyconst {
Mutex,
WorkerPool,
Scheduler,
ConcurrentQueue,
parallelPipeline,
} = require('dahlia-concurrency');
const mutex = new Mutex();
const q = new ConcurrentQueue();
q.enqueue(1); q.enqueue(2);
const pool = new WorkerPool(2, require('node:path').resolve(__dirname, 'worker.js'));
const scheduler = new Scheduler(2, require('node:path').resolve(__dirname, 'handlers.js'));
scheduler.start();