MCPcopy
hub / github.com/microsoft/vscode-languageserver-node / CancellationTokenSource

Class CancellationTokenSource

jsonrpc/src/cancellation.ts:83–110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

81}
82
83export class CancellationTokenSource {
84
85 private _token: CancellationToken;
86
87 get token(): CancellationToken {
88 if (!this._token) {
89 // be lazy and create the token only when
90 // actually needed
91 this._token = new MutableToken();
92 }
93 return this._token;
94 }
95
96 cancel(): void {
97 if (!this._token) {
98 // save an object by returning the default
99 // cancelled token when cancellation happens
100 // before someone asks for the token
101 this._token = CancellationToken.Cancelled;
102 } else {
103 (<MutableToken>this._token).cancel();
104 }
105 }
106
107 dispose(): void {
108 this.cancel();
109 }
110}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected