Enable processing plugins as soon as there is one available worker
This commit is contained in:
parent
38d3536340
commit
fd7d22e16a
@ -30,7 +30,7 @@ const DataDirPicker: React.FC<Props> = () => {
|
|||||||
const onDataDirButtonClick = async (event: {
|
const onDataDirButtonClick = async (event: {
|
||||||
target: { files: FileList | null };
|
target: { files: FileList | null };
|
||||||
}) => {
|
}) => {
|
||||||
if (!workerPool) {
|
if (!workerPool || workerPool.availableWorkers.length === 0) {
|
||||||
return alert("Workers not loaded yet");
|
return alert("Workers not loaded yet");
|
||||||
}
|
}
|
||||||
const files = event.target.files ?? [];
|
const files = event.target.files ?? [];
|
||||||
|
@ -58,7 +58,7 @@ export const DropZone: React.FC<Props> = ({ children, workerPool }) => {
|
|||||||
const pluginFiles = await Promise.all(
|
const pluginFiles = await Promise.all(
|
||||||
plugins.map(async (plugin) => plugin.getFile())
|
plugins.map(async (plugin) => plugin.getFile())
|
||||||
);
|
);
|
||||||
if (workerPool) {
|
if (workerPool && workerPool.availableWorkers.length > 0) {
|
||||||
parsePluginFiles(pluginFiles, workerPool);
|
parsePluginFiles(pluginFiles, workerPool);
|
||||||
} else {
|
} else {
|
||||||
alert("Workers not loaded yet");
|
alert("Workers not loaded yet");
|
||||||
@ -117,7 +117,7 @@ export const DropZone: React.FC<Props> = ({ children, workerPool }) => {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
if (workerPool) {
|
if (workerPool && workerPool.availableWorkers.length > 0) {
|
||||||
parsePluginFiles(pluginFiles, workerPool);
|
parsePluginFiles(pluginFiles, workerPool);
|
||||||
} else {
|
} else {
|
||||||
alert("Workers not loaded yet");
|
alert("Workers not loaded yet");
|
||||||
|
@ -26,7 +26,7 @@ export class WorkerPool {
|
|||||||
public async init(count: number = window.navigator.hardwareConcurrency ?? 8): Promise<WorkerPool> {
|
public async init(count: number = window.navigator.hardwareConcurrency ?? 8): Promise<WorkerPool> {
|
||||||
this.availableWorkers = [];
|
this.availableWorkers = [];
|
||||||
for (let i = 0; i < count; i++) {
|
for (let i = 0; i < count; i++) {
|
||||||
this.availableWorkers.push(await this.createWorker());
|
this.createWorker().then(worker => this.availableWorkers.push(worker));
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user