Skip to content
/ dahlia Public

Lightweight concurrency and parallelism toolkit for Node.js built on worker_threads

License

Notifications You must be signed in to change notification settings

hhuziuk/dahlia

Repository files navigation

Dahlia Concurrency — Documentation

Lightweight concurrency and parallelism toolkit for Node.js built on worker_threads.

What’s inside

  • Primitives: Mutex, RwLock, CountingSemaphore, BinarySemaphore, WorkerPool
  • Data structures: ConcurrentQueue, ConcurrentPriorityQueue, ConcurrentDeque, ConcurrentStack, ConcurrentSet
  • Methods: parallelPipeline(...), parallelQuickSort(...) and quick-sort utilities
  • Task scheduler: Scheduler

Install

npm install dahlia-concurrency

Quick start

const {
  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();

Documentation

About

Lightweight concurrency and parallelism toolkit for Node.js built on worker_threads

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published