Skip to content

Commit

Permalink
remove empty cancel callback from promise constructions #56137
Browse files Browse the repository at this point in the history
  • Loading branch information
jrieken committed Sep 10, 2018
1 parent 8ad3bcf commit e433e7c
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 20 deletions.
10 changes: 3 additions & 7 deletions src/vs/base/common/async.ts
Expand Up @@ -68,7 +68,7 @@ export function asThenable<T>(callback: () => T | TPromise<T> | Thenable<T>): Th
} else {
resolve(item);
}
}, () => { /* not supported */ });
});
}

export interface ITask<T> {
Expand Down Expand Up @@ -136,8 +136,6 @@ export class Throttler {

return new TPromise((c, e) => {
this.queuedPromise.then(c, e);
}, () => {
// no-op
});
}

Expand Down Expand Up @@ -287,8 +285,6 @@ export class Barrier {
this._isOpen = false;
this._promise = new TPromise<boolean>((c, e) => {
this._completePromise = c;
}, () => {
console.warn('You should really not try to cancel this ready promise!');
});
}

Expand Down Expand Up @@ -712,11 +708,11 @@ export class RunOnceWorker<T> extends RunOnceScheduler {
export function nfcall(fn: Function, ...args: any[]): TPromise;
export function nfcall<T>(fn: Function, ...args: any[]): TPromise<T>;
export function nfcall(fn: Function, ...args: any[]): any {
return new TPromise((c, e) => fn(...args, (err: any, result: any) => err ? e(err) : c(result)), () => null);
return new TPromise((c, e) => fn(...args, (err: any, result: any) => err ? e(err) : c(result)));
}

export function ninvoke(thisArg: any, fn: Function, ...args: any[]): TPromise;
export function ninvoke<T>(thisArg: any, fn: Function, ...args: any[]): TPromise<T>;
export function ninvoke(thisArg: any, fn: Function, ...args: any[]): any {
return new TPromise((c, e) => fn.call(thisArg, ...args, (err: any, result: any) => err ? e(err) : c(result)), () => null);
return new TPromise((c, e) => fn.call(thisArg, ...args, (err: any, result: any) => err ? e(err) : c(result)));
}
6 changes: 1 addition & 5 deletions src/vs/base/common/worker/simpleWorker.ts
Expand Up @@ -94,8 +94,6 @@ class SimpleWorkerProtocol {
let result = new TPromise<any>((c, e) => {
reply.c = c;
reply.e = e;
}, () => {
// Cancel not supported
});
this._pendingReplies[req] = reply;

Expand Down Expand Up @@ -235,7 +233,7 @@ export class SimpleWorkerClient<T> extends Disposable {
this._lazyProxy = new TPromise<T>((c, e) => {
lazyProxyFulfill = c;
lazyProxyReject = e;
}, () => { /* no cancel */ });
});

// Send initialize message
this._onModuleLoaded = this._protocol.sendMessage(INITIALIZE, [
Expand Down Expand Up @@ -277,8 +275,6 @@ export class SimpleWorkerClient<T> extends Disposable {
this._onModuleLoaded.then(() => {
this._protocol.sendMessage(method, args).then(c, e);
}, e);
}, () => {
// Cancel intentionally not supported
});
}

Expand Down
4 changes: 2 additions & 2 deletions src/vs/base/node/pfs.ts
Expand Up @@ -19,7 +19,7 @@ export function readdir(path: string): TPromise<string[]> {
}

export function exists(path: string): TPromise<boolean> {
return new TPromise(c => fs.exists(path, c), () => { });
return new TPromise(c => fs.exists(path, c));
}

export function chmod(path: string, mode: number): TPromise<boolean> {
Expand Down Expand Up @@ -194,4 +194,4 @@ export function whenDeleted(path: string): TPromise<void> {

export function copy(source: string, target: string): TPromise<void> {
return nfcall(extfs.copy, source, target);
}
}
Expand Up @@ -885,7 +885,7 @@ export class ExtensionManagementService extends Disposable implements IExtension
}

private toNonCancellablePromise<T>(promise: TPromise<T>): TPromise<T> {
return new TPromise((c, e) => promise.then(result => c(result), error => e(error)), () => this.logService.debug('Request Cancelled'));
return new TPromise((c, e) => promise.then(result => c(result), error => e(error)));
}

private reportTelemetry(eventName: string, extensionData: any, duration: number, error?: Error): void {
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/parts/debug/node/terminals.ts
Expand Up @@ -55,7 +55,7 @@ export function getDefaultTerminalLinuxReady(): TPromise<string> {
}

c('xterm');
}, () => { });
});
}
return _DEFAULT_TERMINAL_LINUX_READY;
}
Expand Down
Expand Up @@ -32,7 +32,7 @@ export function getDefaultTerminalLinuxReady(): TPromise<string> {
}

c('xterm');
}, () => { });
});
}
return _DEFAULT_TERMINAL_LINUX_READY;
}
Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/parts/tasks/common/problemMatcher.ts
Expand Up @@ -1088,7 +1088,7 @@ class ProblemPatternRegistryImpl implements IProblemPatternRegistry {
}
resolve(undefined);
});
}, () => { });
});
}

public onReady(): TPromise<void> {
Expand Down Expand Up @@ -1642,7 +1642,7 @@ class ProblemMatcherRegistryImpl implements IProblemMatcherRegistry {
}
resolve(undefined);
});
}, () => { });
});
}

public onReady(): TPromise<void> {
Expand Down
Expand Up @@ -107,7 +107,7 @@ class TaskDefinitionRegistryImpl implements ITaskDefinitionRegistry {
}
resolve(undefined);
});
}, () => { });
});
}

public onReady(): TPromise<void> {
Expand Down

0 comments on commit e433e7c

Please sign in to comment.