0.2.6 • Published 6 years ago

async-pool v0.2.6

Weekly downloads
7
License
ISC
Repository
github
Last release
6 years ago

async-pool

asynchronous resource pool using bluebird

Installation

npm install async-pool

Usage

AsyncPool = require 'async-pool'
Promise = require 'bluebird'

pool = new AsyncPool(['foo', 'bar', 'baz'])

Promise.map [1..8], (i)->
  Promise.using pool.use(), (s)->
    console.log(s, pool.resources.length, pool.waiting.length)
    if i % 2 == 0
      throw new Error("Even numbers are bad luck.")
  .catch (err)->
  

Produces:

baz 0 5
bar 0 5
foo 0 5
baz 0 2
bar 0 2
foo 0 2
baz 1 0
bar 1 0
  

Also see async-proxy-pool which extends async pool, supporting parallel as well as serial access.

0.2.6

6 years ago

0.2.5

9 years ago

0.2.3

9 years ago

0.2.1

9 years ago

0.2.0

9 years ago

0.1.0

9 years ago

0.0.1

9 years ago