-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
19 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; | ||
|
||
|
@@ -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) { | ||
|
@@ -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']; | ||
|