MCPcopy Create free account
hub / github.com/microsoft/vscode-cpptools / enqueue

Method enqueue

Extension/src/LanguageServer/client.ts:2547–2564  ·  view source on GitHub ↗

* Enqueue a task to ensure that the order is maintained. The tasks are executed sequentially after the client is ready. * * this is a bit more expensive than `.ready` - this ensures the task is absolutely finished executing before allowing * the dispatcher to move forward. *

(task: () => Promise<T>)

Source from the content-addressed store, hash-verified

2545 * Use `await <client>.ready` when you need to ensure that the client is initialized, and still run in order.
2546 */
2547 enqueue<T>(task: () => Promise<T>) {
2548 ok(this.isSupported, localize("unsupported.client", "Unsupported client"));
2549
2550 // create a placeholder promise that is resolved when the task is complete.
2551 const result = new ManualPromise<unknown>();
2552
2553 // add the task to the queue
2554 DefaultClient.queue.push([result, task]);
2555
2556 // if we're not already dispatching, start
2557 if (DefaultClient.dispatching.isSet) {
2558 // start dispatching
2559 void DefaultClient.dispatch();
2560 }
2561
2562 // return the placeholder promise to the caller.
2563 return result as Promise<T>;
2564 }
2565
2566 /**
2567 * The dispatch loop asynchronously processes items in the async queue in order, and ensures that tasks are dispatched in the

Callers 1

Calls 2

pushMethod · 0.80
dispatchMethod · 0.80

Tested by

no test coverage detected