Last change
on this file since b738035 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
490 bytes
|
Rev | Line | |
---|
[6a3a178] | 1 | #!/usr/bin/env node
|
---|
| 2 | var assert = require('assert');
|
---|
| 3 | var qjob = require('../qjobs');
|
---|
| 4 |
|
---|
| 5 | // only 2 jobs in the same time
|
---|
| 6 | var q = new qjob({maxConcurrency:2});
|
---|
| 7 |
|
---|
| 8 | var testExecutedJobs = 0;
|
---|
| 9 |
|
---|
| 10 | var myjob = function(args,next) {
|
---|
| 11 | setTimeout(function() {
|
---|
| 12 | testExecutedJobs++;
|
---|
| 13 | next();
|
---|
| 14 | },50);
|
---|
| 15 | }
|
---|
| 16 |
|
---|
| 17 | // Let's add 10 job and add them to the queue
|
---|
| 18 | for (var i = 0; i<10; i++) {
|
---|
| 19 | q.add(myjob,['test'+i]);
|
---|
| 20 | }
|
---|
| 21 |
|
---|
| 22 | q.on('end',function() {
|
---|
| 23 | assert.equal(testExecutedJobs, 10);
|
---|
| 24 | });
|
---|
| 25 |
|
---|
| 26 | q.run();
|
---|
| 27 |
|
---|
| 28 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.