377
378
initialize(): Promise<void> {
379
>
if (!this.initializationPromise) {
storage.ts
380
>
this.initializationPromise = (async () => {
381
>
382
>
// Init all storage locations
383
>
mark('code/willInitStorage');
384
>
try {
385
>
await this.doInitialize(); // Ask subclasses to initialize storage
386
>
} finally {
387
>
mark('code/didInitStorage');
388
>
}
389
>
390
>
// On some OS we do not get enough time to persist state on shutdown (e.g. when
391
>
// Windows restarts after applying updates). In other cases, VSCode might crash,
392
>
// so we periodically save state to reduce the chance of loosing any state.
393
>
// In the browser we do not have support for long running unload sequences. As such,
394
>
// we cannot ask for saving state in that moment, because that would result in a
395
>
// long running operation.
396
>
// Instead, periodically ask customers to save save. The library will be clever enough
397
>
// to only save state that has actually changed.
398
>
this.flushWhenIdleScheduler.schedule();
399
>
})();
400
>
}
401
>
402
>
return this.initializationPromise;
403
>
}
404
405
protected emitDidChangeValue(scope: StorageScope, event: IStorageChangeEvent): void {