in extensions/gnome-extension/src/extension.ts [903:946]
push(new_item) {
if (!(new_item instanceof Queue.Item))
throw TypeError("Expected a Queue.Item");
this.#items.push(new_item);
if (this.#running) {
this.#on_item_push();
return this;
}
(async () => {
this.#running = true;
let item = this.#items.shift();
while (item) {
try {
const value = item._();
if ("cancel" in value && "promise" in value) {
const { promise, cancel } = value;
if (this.#items.length === 0) {
await promise;
this.#on_item_push = () => {};
} else {
await cancel();
}
} else if (value instanceof Promise) {
await value;
}
} catch (error) {
log_msg(`Uncaught error in Queue: ${error}`);
}
item = this.#items.shift();
}
this.#running = false;
})();
return this;
}