Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
dispose() {
if (this.m_serviceCreated) {
this.workerSet
.broadcastRequest(WorkerServiceProtocol.WORKER_SERVICE_MANAGER_SERVICE_ID, {
type: WorkerServiceProtocol.Requests.DestroyService,
targetServiceId: this.serviceId
})
.catch(() => {
/* Ignoring these errors as underlying workers possibly do not exist anymore. */
});
}
this.workerSet.removeReference();
}
dispose() {
if (this.m_serviceCreated) {
this.workerSet
.broadcastRequest(WorkerServiceProtocol.WORKER_SERVICE_MANAGER_SERVICE_ID, {
type: WorkerServiceProtocol.Requests.DestroyService,
targetServiceId: this.serviceId
})
.catch(() => {
/* Ignoring these errors as underlying workers possibly do not exist anymore. */
});
}
this.workerSet.removeReference();
}
static getInstance() {
if (this.m_service === undefined) {
this.m_service = new WorkerServiceManager(
WorkerServiceProtocol.WORKER_SERVICE_MANAGER_SERVICE_ID
);
}
return this.m_service;
}
private constructor(
serviceId: string = WorkerServiceProtocol.WORKER_SERVICE_MANAGER_SERVICE_ID
) {
super(serviceId);
}
async connect(): Promise {
await this.workerSet.connect(WorkerServiceProtocol.WORKER_SERVICE_MANAGER_SERVICE_ID);
if (!this.m_serviceCreated) {
await this.workerSet.broadcastRequest(
WorkerServiceProtocol.WORKER_SERVICE_MANAGER_SERVICE_ID,
{
type: WorkerServiceProtocol.Requests.CreateService,
targetServiceType: this.tilerServiceType,
targetServiceId: this.serviceId
}
);
this.m_serviceCreated = true;
}
}
async connect(): Promise {
await this.workerSet.connect(WorkerServiceProtocol.WORKER_SERVICE_MANAGER_SERVICE_ID);
if (!this.m_serviceCreated) {
await this.workerSet.broadcastRequest(
WorkerServiceProtocol.WORKER_SERVICE_MANAGER_SERVICE_ID,
{
type: WorkerServiceProtocol.Requests.CreateService,
targetServiceType: this.decoderServiceType,
targetServiceId: this.serviceId
}
);
this.m_serviceCreated = true;
}
}