New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@esfx/threading-countdown

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@esfx/threading-countdown

Provides 'CountdownEvent', a thread synchronization primitive for use with Workers

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

@esfx/threading-countdown

Provides CountdownEvent, a thread synchronization primitive for use with Workers.

Overview

  • Installation
  • Usage
  • API

Installation

npm i @esfx/threading-countdown

Usage

import { Worker, isMainThread, parentPort, workerData } from "worker_threads";
import { CountdownEvent } from "@esfx/threading-countdown";

function worker_thread() {
    const countdown = new CountdownEvent(workerData);

    // do work in background...

    // signal worker is finished
    countdown.signal();
}

function main() {
    const countdown = new CountdownEvent(5);

    // start 5 workers
    for (let i = 0; i < 5; i++) {
        new Worker(__filename, { workerData: countdown.buffer });
    }

    // wait for the workers to finish
    countdown.wait();
}

if (isMainThread) {
    main();
}
else {
    worker_thread();
}

API

You can read more about the API here.

FAQs

Package last updated on 20 Oct 2022

Did you know?

Socket

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.

Install

Related posts