File: concurrency.js

package info (click to toggle)
node-batch 0.6.1-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 140 kB
  • sloc: javascript: 282; makefile: 8
file content (25 lines) | stat: -rw-r--r-- 352 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

/**
 * Module dependencies.
 */

var Batch = require('..');

var n = 10;
var batch = new Batch;

batch.concurrency(2);

while (n--) {
  (function(n){
    batch.push(function(done){
      console.log('  start : %s', n);
      setTimeout(function(){
        console.log('   done : %s', n);
        done();
      }, 200);
    })
  })(n);
}

batch.end();