mirror of
https://github.com/microsoft/vscode.git
synced 2026-07-26 07:57:09 +01:00
CancellationTokenSource.dispose() should not cancel() (#46102)
* debt - dispose one CancellationTokenSource * CancellationTokenSource.dispose() should not cancel() fixes #46101 * CancellationToken.None when disposing
This commit is contained in:
@@ -45,8 +45,7 @@ class MutableToken implements CancellationToken {
|
||||
this._isCancelled = true;
|
||||
if (this._emitter) {
|
||||
this._emitter.fire(undefined);
|
||||
this._emitter.dispose();
|
||||
this._emitter = undefined;
|
||||
this.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -64,6 +63,13 @@ class MutableToken implements CancellationToken {
|
||||
}
|
||||
return this._emitter.event;
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
if (this._emitter) {
|
||||
this._emitter.dispose();
|
||||
this._emitter = undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class CancellationTokenSource {
|
||||
@@ -93,6 +99,13 @@ export class CancellationTokenSource {
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
this.cancel();
|
||||
if (!this._token) {
|
||||
// ensure to initialize with an empty token if we had none
|
||||
this._token = CancellationToken.None;
|
||||
|
||||
} else if (this._token instanceof MutableToken) {
|
||||
// actually dispose
|
||||
this._token.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -1329,7 +1329,7 @@ declare module 'vscode' {
|
||||
cancel(): void;
|
||||
|
||||
/**
|
||||
* Dispose object and free resources. Will call [cancel](#CancellationTokenSource.cancel).
|
||||
* Dispose object and free resources.
|
||||
*/
|
||||
dispose(): void;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user