Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve queues, (one effect: improve code completion) #4310

Merged
merged 8 commits into from
Jan 4, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
call dequeue when cancelRequest is called
add some logging
an-dr-eas-k committed Dec 21, 2020
commit 954ce958a4aca875c1de3bee565c757c8624aa53
16 changes: 15 additions & 1 deletion src/omnisharp/requestQueue.ts
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@ export interface Request {
onError(err: any): void;
startTime?: number;
endTime?: number;
id?: number;
}

/**
@@ -62,7 +63,11 @@ class RequestQueue {
request.onError(new Error(`Pending request cancelled: ${request.command}`));
}

// TODO: Handle cancellation of a request already waiting on the OmniSharp server.
console.log(`canceling waiting request ${request.command} ${request.id}`);
if (request.id){
console.log(`dequeueing request ${request.command} with id ${request.id}`);
this.dequeue(request.id);
}
}

/**
@@ -84,18 +89,21 @@ class RequestQueue {
*/
public processPending() {
if (this._pending.length === 0) {
console.log("non pending: break");
return;
}

this.eventStream.post(new OmnisharpServerProcessRequestStart(this._name));

const slots = this._maxSize - this._waiting.size;
console.log(`slots available: ${slots}`);

for (let i = 0; i < slots && this._pending.length > 0; i++) {
const item = this._pending.shift();
item.startTime = Date.now();

const id = this._makeRequest(item);
console.log(`requested: ${item.command}, id: ${id}`);
this._waiting.set(id, item);

if (this.isFull()) {
@@ -159,30 +167,36 @@ export class RequestQueueCollection {

public drain() {
if (this._isProcessing) {
console.log("is processing: break");
return false;
}

if (this._priorityQueue.isFull()) {
console.log("priority queue is full: break");
return false;
}

if (this._normalQueue.isFull() && this._deferredQueue.isFull()) {
console.log("other queues are full: break");
return false;
}

this._isProcessing = true;

if (this._priorityQueue.hasPending()) {
console.log("processing priority queue");
this._priorityQueue.processPending();
this._isProcessing = false;
return;
}

if (this._normalQueue.hasPending()) {
console.log("processing normal queue");
this._normalQueue.processPending();
}

if (this._deferredQueue.hasPending()) {
console.log("processing deferred queue");
this._deferredQueue.processPending();
}

3 changes: 2 additions & 1 deletion src/omnisharp/server.ts
Original file line number Diff line number Diff line change
@@ -705,7 +705,8 @@ export class OmniSharpServer {

private _makeRequest(request: Request) {
const id = OmniSharpServer._nextId++;

request.id = id;

333fred marked this conversation as resolved.
Show resolved Hide resolved
const requestPacket: protocol.WireProtocol.RequestPacket = {
Type: 'request',
Seq: id,