/usr/lib/nodejs/tilelive/lib/queue.js is in node-tilelive 4.5.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | var util = require('util');
var EventEmitter = require('events').EventEmitter;
module.exports = Queue;
function Queue(callback, concurrency) {
this.callback = callback;
this.concurrency = concurrency || 10;
this.next = this.next.bind(this);
this.invoke = this.invoke.bind(this);
this.queue = [];
this.running = 0;
}
util.inherits(Queue, EventEmitter);
Queue.prototype.add = function(item) {
this.queue.push(item);
if (this.running < this.concurrency) {
this.running++;
this.next();
}
};
Queue.prototype.invoke = function() {
if (this.queue.length) {
this.callback(this.queue.shift(), this.next);
} else {
this.next();
}
};
Queue.prototype.next = function(err) {
if (this.queue.length) {
process.nextTick(this.invoke);
} else {
this.running--;
if (!this.running) {
this.emit('empty');
}
}
};
|