Skip to content

Commit

Permalink
fix: use a barrier instead of an event
Browse files Browse the repository at this point in the history
  • Loading branch information
Loïc Mangeonjean committed Jun 5, 2023
1 parent 3fe3d4e commit 2af9708
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/vscode-services/extHost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import { InstantiationType, registerSingleton } from 'vs/platform/instantiation/
import { IMessagePassingProtocol } from 'vs/base/parts/ipc/common/ipc'
import { BufferedEmitter } from 'vs/base/parts/ipc/common/ipc.net'
import { VSBuffer } from 'vs/base/common/buffer'
import { Emitter, Event } from 'vs/base/common/event'
import { Event } from 'vs/base/common/event'
import { RPCProtocol } from 'vs/workbench/services/extensions/common/rpcProtocol'
import { ExtHostConsumerFileSystem, IExtHostConsumerFileSystem } from 'vs/workbench/api/common/extHostFileSystemConsumer'
import { IExtHostInitDataService } from 'vs/workbench/api/common/extHostInitDataService'
Expand Down Expand Up @@ -84,6 +84,7 @@ import 'vs/workbench/api/browser/mainThreadSaveParticipant'
import 'vs/workbench/api/browser/mainThreadTreeViews'
import 'vs/workbench/api/browser/mainThreadStorage'
import * as errors from 'vs/base/common/errors'
import { Barrier } from 'vs/base/common/async'
import { unsupported } from '../tools'

const original = MainThreadMessageService.prototype.$showMessage
Expand Down Expand Up @@ -421,13 +422,15 @@ let configProvider: ExtHostConfigProvider | undefined

let initializePromise: Promise<void> | undefined

const extHostInitializedEmitter = new Emitter<void>()
export const onExtHostInitialized: Event<void> = extHostInitializedEmitter.event
const extHostInitializedBarrier = new Barrier()
export function onExtHostInitialized (fct: () => void): void {
void extHostInitializedBarrier.wait().then(fct)
}

async function _initialize (): Promise<void> {
extHostServices = await createExtHostServices()
configProvider = await extHostServices.extHostConfiguration.getConfigProvider()
extHostInitializedEmitter.fire()
extHostInitializedBarrier.open()
}

export async function initialize (): Promise<void> {
Expand Down

0 comments on commit 2af9708

Please sign in to comment.