All Projects β†’ wilk β†’ Microjob

wilk / Microjob

Licence: mit
A tiny wrapper for turning Node.js worker threads into easy-to-use routines for heavy CPU loads.

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Microjob

React Native Multithreading
🧡 Fast and easy multithreading for React Native using JSI
Stars: ✭ 164 (-91.74%)
Mutual labels:  multithreading, thread, threading
Thread
type safe multi-threading made easier
Stars: ✭ 34 (-98.29%)
Mutual labels:  thread, multithreading, threading
ObviousAwait
🧡 Expressive aliases to ConfigureAwait(true) and ConfigureAwait(false)
Stars: ✭ 55 (-97.23%)
Mutual labels:  thread, multithreading, threading
theater
Actor framework for Dart. This package makes it easier to work with isolates, create clusters of isolates.
Stars: ✭ 29 (-98.54%)
Mutual labels:  thread, multithreading
react-native-bg-thread
react-native-bg-thread
Stars: ✭ 45 (-97.73%)
Mutual labels:  multithreading, threading
spinach
Modern Redis task queue for Python 3
Stars: ✭ 46 (-97.68%)
Mutual labels:  thread, jobs
awesome-dotnet-async
A curated list of awesome articles and resources to learning and practicing about async, threading, and channels in .Net platform. πŸ˜‰
Stars: ✭ 84 (-95.77%)
Mutual labels:  thread, threading
dannyAVgleDownloader
ηŸ₯名碲站avgle下載器
Stars: ✭ 27 (-98.64%)
Mutual labels:  multithreading, threading
Concurrencpp
Modern concurrency for C++. Tasks, executors, timers and C++20 coroutines to rule them all
Stars: ✭ 340 (-82.87%)
Mutual labels:  multithreading, threading
Interlace
Easily turn single threaded command line applications into a fast, multi-threaded application with CIDR and glob support.
Stars: ✭ 760 (-61.71%)
Mutual labels:  multithreading, thread
Swiftcoroutine
Swift coroutines for iOS, macOS and Linux.
Stars: ✭ 690 (-65.24%)
Mutual labels:  multithreading, thread
Thread Loader
Runs the following loaders in a worker pool
Stars: ✭ 945 (-52.39%)
Mutual labels:  multithreading, thread
ECS-Phyllotaxis
Learning ECS - 100k Cubes in Phyllotaxis pattern
Stars: ✭ 17 (-99.14%)
Mutual labels:  jobs, multithreading
thread-pool
BS::thread_pool: a fast, lightweight, and easy-to-use C++17 thread pool library
Stars: ✭ 1,043 (-47.46%)
Mutual labels:  multithreading, threading
Pelagia
Automatic parallelization (lock-free multithreading thread) tool developed by Surparallel Open Source.Pelagia is embedded key value database that implements a small, fast, high-reliability on ANSI C.
Stars: ✭ 1,132 (-42.97%)
Mutual labels:  multithreading, thread
Track-Stargazers
Have fun tracking your project's stargazers
Stars: ✭ 38 (-98.09%)
Mutual labels:  multithreading, threading
Java Concurrency Examples
Java Concurrency/Multithreading Tutorial with Examples for Dummies
Stars: ✭ 173 (-91.28%)
Mutual labels:  multithreading, thread
Pht
A new threading extension for PHP
Stars: ✭ 175 (-91.18%)
Mutual labels:  multithreading, threading
Hamsters.js
100% Vanilla Javascript Multithreading & Parallel Execution Library
Stars: ✭ 517 (-73.95%)
Mutual labels:  multithreading, thread
Enkits
A permissively licensed C and C++ Task Scheduler for creating parallel programs. Requires C++11 support.
Stars: ✭ 962 (-51.54%)
Mutual labels:  multithreading, thread

Microjob

npm version Build Status Coverage Status Dependencies

A tiny wrapper for turning Node.js threads in easy-to-use routines for CPU-bound.

Introduction

Microjob is a tiny wrapper for Node.js threads and is intended to perform heavy CPU loads using anonymous functions.

So, Microjob treats Node.js threads as temporary working units: if you need to spawn a long-living thread, then you should use the default API.

From version v0.1.0 microjob uses a Worker Pool πŸŽ‰

Microjob follows the same line of the original Node.js documentation: use it only for CPU-bound jobs and not for I/O-bound purposes. Quoting the documentation:

Workers are useful for performing CPU-intensive JavaScript operations; do not use them for I/O, since Node.js’s built-in mechanisms for performing operations asynchronously already treat it more efficiently than Worker threads can.

Microjob can be used with Node.js 12+ without flag. With Node.js 10.5+ you need the --experimental-worker flag activated, otherwise it won't work.

More details explained in: Microjob: a tiny multithreading library for Node.js

Installation

Via npm:

$ npm install --save microjob

Quick Example

(async () => {
  const { job, start, stop } = require("microjob");

  try {
    // start the worker pool
    await start();

    // this function will be executed in another thread
    const res = await job(() => {
      let i = 0;
      for (i = 0; i < 1000000; i++) {
        // heavy CPU load ...
      }

      return i;
    });

    console.log(res); // 1000000
  } catch (err) {
    console.error(err);
  } finally {
    // shutdown worker pool
    await stop();
  }
})();

Features

  • πŸ›’οΈ Worker Pool
  • πŸ₯ auto self-healing
  • πŸ™Œ easy and simple
  • πŸ•” supports both sync and async jobs
  • πŸ›‘οΈ huge test coverage
  • πŸ“œ well documented

Documentation

Dive deep into the documentation to find more examples: Guide

Known Issues

Known Limitations

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].