Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
ggazzo committed Dec 19, 2024
1 parent 0dc17e9 commit 074f1c5
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions packages/apps-engine/deno-runtime/lib/messenger.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { writeAll } from "https://deno.land/[email protected]/io/write_all.ts";
import { writeAll } from 'https://deno.land/[email protected]/io/write_all.ts';

import * as jsonrpc from 'jsonrpc-lite';

Expand Down Expand Up @@ -38,21 +38,28 @@ export const Queue = new (class Queue {
private isProcessing = false;

private async processQueue() {
if (this.isProcessing) {
return;
}
try {
if (this.isProcessing) {
return;
}

this.isProcessing = true;
this.isProcessing = true;

while (this.queue.length) {
const message = this.queue.shift();
while (this.queue.length) {
const [message] = this.queue;

if (message) {
await Transport.send(message);
if (message) {
await Transport.send(message);
}
this.queue.shift();
}
}

this.isProcessing = false;
this.isProcessing = false;
} catch (error) {
throw error;
} finally {
this.isProcessing = false;
}
}

public enqueue(message: jsonrpc.JsonRpc | typeof COMMAND_PONG) {
Expand All @@ -63,7 +70,7 @@ export const Queue = new (class Queue {
public getCurrentSize() {
return this.queue.length;
}
});
})();

export const Transport = new (class Transporter {
private selectedTransport: Transporter['stdoutTransport'] | Transporter['noopTransport'];
Expand Down

0 comments on commit 074f1c5

Please sign in to comment.