mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-18 07:29:16 -05:00
Wrapping LSHost's cancellationtoken with a throttle
This commit is contained in:
@@ -270,7 +270,8 @@ namespace ts.server {
|
||||
public readonly cancellationToken: HostCancellationToken,
|
||||
public readonly useSingleInferredProject: boolean,
|
||||
readonly typingsInstaller: ITypingsInstaller = nullTypingsInstaller,
|
||||
private readonly eventHandler?: ProjectServiceEventHandler) {
|
||||
private readonly eventHandler?: ProjectServiceEventHandler,
|
||||
public readonly throttleWaitMilliseconds?: number) {
|
||||
|
||||
Debug.assert(!!host.createHash, "'ServerHost.createHash' is required for ProjectService");
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ namespace ts.server {
|
||||
readonly realpath?: (path: string) => string;
|
||||
|
||||
constructor(private readonly host: ServerHost, private readonly project: Project, private readonly cancellationToken: HostCancellationToken) {
|
||||
this.cancellationToken = new ThrottledCancellationToken(cancellationToken, project.projectService.throttleWaitMilliseconds);
|
||||
this.getCanonicalFileName = ts.createGetCanonicalFileName(this.host.useCaseSensitiveFileNames);
|
||||
|
||||
if (host.trace) {
|
||||
|
||||
@@ -338,7 +338,8 @@ namespace ts.server {
|
||||
private hrtime: (start?: number[]) => number[],
|
||||
protected logger: Logger,
|
||||
protected readonly canUseEvents: boolean,
|
||||
eventHandler?: ProjectServiceEventHandler) {
|
||||
eventHandler?: ProjectServiceEventHandler,
|
||||
private readonly throttleWaitMilliseconds?: number) {
|
||||
|
||||
this.eventHander = canUseEvents
|
||||
? eventHandler || (event => this.defaultEventHandler(event))
|
||||
@@ -353,7 +354,7 @@ namespace ts.server {
|
||||
isCancellationRequested: () => cancellationToken.isCancellationRequested()
|
||||
}
|
||||
this.errorCheck = new MultistepOperation(multistepOperationHost);
|
||||
this.projectService = new ProjectService(host, logger, cancellationToken, useSingleInferredProject, typingsInstaller, this.eventHander);
|
||||
this.projectService = new ProjectService(host, logger, cancellationToken, useSingleInferredProject, typingsInstaller, this.eventHander, this.throttleWaitMilliseconds);
|
||||
this.gcTimer = new GcTimer(host, /*delay*/ 7000, logger);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user