Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fixed-size-executor

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fixed-size-executor

Submit async jobs to an executor, but limit how many can run concurrently

  • 0.1.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

fixed-size-executor

Submit async jobs to an executor, but limit how many can run concurrently

Synopsis

var FixedSizeExecutor = require('fixed-size-executor');

// Create an executor, specify the maximum concurrency
executor = new FixedSizeExecutor(2);

// A simple "job" function which takes a little time to run
var t0 = new Date().getTime() - 10000;
var slowGreeter = function (nextJob, arg1, arg2) {
    console.log("", new Date().getTime()-t0, "Hello", arg1, "...");
    setTimeout(function () {
        console.log("", new Date().getTime()-t0, "... Hello", arg1, arg2);
        nextJob();
    }, 2000 * Math.random());
};

// Submit jobs to the executor (function to call, plus 0..n args to pass)
// Here we happen to use the same function every time
executor.submit(slowGreeter, "One", "1");
executor.submit(slowGreeter, "Two", "2");
executor.submit(slowGreeter, "Three", "3");
executor.submit(slowGreeter, "Four", "4");

setTimeout(function () {
        executor.submit(slowGreeter, "Five", "5");
}, 5000);

An executor can also be stringified - toString() shows information about the state of the executor.

FAQs

Package last updated on 01 Dec 2015

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc