Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /var/www/html/wincloud_gateway/node_modules/bull/node_modules/ioredis/built/cluster/ drwxr-xr-x | |
| Viewing file: Select action/file-type: "use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("../utils");
const Deque = require("denque");
const debug = utils_1.Debug("delayqueue");
/**
* Queue that runs items after specified duration
*
* @export
* @class DelayQueue
*/
class DelayQueue {
constructor() {
this.queues = {};
this.timeouts = {};
}
/**
* Add a new item to the queue
*
* @param {string} bucket bucket name
* @param {Function} item function that will run later
* @param {IDelayQueueOptions} options
* @memberof DelayQueue
*/
push(bucket, item, options) {
const callback = options.callback || process.nextTick;
if (!this.queues[bucket]) {
this.queues[bucket] = new Deque();
}
const queue = this.queues[bucket];
queue.push(item);
if (!this.timeouts[bucket]) {
this.timeouts[bucket] = setTimeout(() => {
callback(() => {
this.timeouts[bucket] = null;
this.execute(bucket);
});
}, options.timeout);
}
}
execute(bucket) {
const queue = this.queues[bucket];
if (!queue) {
return;
}
const { length } = queue;
if (!length) {
return;
}
debug("send %d commands in %s queue", length, bucket);
this.queues[bucket] = null;
while (queue.length > 0) {
queue.shift()();
}
}
}
exports.default = DelayQueue;
|
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0049 ]-- |