|
5 | 5 |
|
6 | 6 | import { getActiveWindow } from '../../../base/browser/dom.js';
|
7 | 7 | import { Disposable, toDisposable, type IDisposable } from '../../../base/common/lifecycle.js';
|
| 8 | +import { IInstantiationService } from '../../../platform/instantiation/common/instantiation.js'; |
| 9 | +import { ILogService } from '../../../platform/log/common/log.js'; |
8 | 10 |
|
9 | 11 | /**
|
10 | 12 | * Copyright (c) 2022 The xterm.js authors. All rights reserved.
|
@@ -41,7 +43,9 @@ abstract class TaskQueue extends Disposable implements ITaskQueue {
|
41 | 43 | private _idleCallback?: number;
|
42 | 44 | private _i = 0;
|
43 | 45 |
|
44 |
| - constructor() { |
| 46 | + constructor( |
| 47 | + @ILogService private readonly _logService: ILogService |
| 48 | + ) { |
45 | 49 | super();
|
46 | 50 | this._register(toDisposable(() => this.clear()));
|
47 | 51 | }
|
@@ -101,7 +105,7 @@ abstract class TaskQueue extends Disposable implements ITaskQueue {
|
101 | 105 | // Warn when the time exceeding the deadline is over 20ms, if this happens in practice the
|
102 | 106 | // task should be split into sub-tasks to ensure the UI remains responsive.
|
103 | 107 | if (lastDeadlineRemaining - taskDuration < -20) {
|
104 |
| - console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(lastDeadlineRemaining - taskDuration))}ms`); |
| 108 | + this._logService.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(lastDeadlineRemaining - taskDuration))}ms`); |
105 | 109 | }
|
106 | 110 | this._start();
|
107 | 111 | return;
|
@@ -161,8 +165,10 @@ export const IdleTaskQueue = ('requestIdleCallback' in getActiveWindow()) ? Idle
|
161 | 165 | export class DebouncedIdleTask {
|
162 | 166 | private _queue: ITaskQueue;
|
163 | 167 |
|
164 |
| - constructor() { |
165 |
| - this._queue = new IdleTaskQueue(); |
| 168 | + constructor( |
| 169 | + @IInstantiationService instantiationService: IInstantiationService |
| 170 | + ) { |
| 171 | + this._queue = instantiationService.createInstance(IdleTaskQueue); |
166 | 172 | }
|
167 | 173 |
|
168 | 174 | public set(task: () => boolean | void): void {
|
|
0 commit comments