From 3dda40a41487f46636d883b401084ce091195953 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81uaksz=20Kwinta?= Date: Fri, 19 Dec 2025 11:07:54 +0100 Subject: [PATCH 1/4] Add cancelation of the geant4 simulation --- src/libs/converter | 2 +- src/services/Geant4LocalWorkerSimulationService.ts | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/libs/converter b/src/libs/converter index 3c4c47f5a..56ce7c213 160000 --- a/src/libs/converter +++ b/src/libs/converter @@ -1 +1 @@ -Subproject commit 3c4c47f5a6d2b88e6f3021ba10bbaab36f7b3e01 +Subproject commit 56ce7c213e1711644a4caf7a13c157e5303db182 diff --git a/src/services/Geant4LocalWorkerSimulationService.ts b/src/services/Geant4LocalWorkerSimulationService.ts index 6ab23b8c7..7f20bb437 100644 --- a/src/services/Geant4LocalWorkerSimulationService.ts +++ b/src/services/Geant4LocalWorkerSimulationService.ts @@ -536,6 +536,13 @@ export default class Geant4LocalWorkerSimulationService implements SimulationSer } cancelJob(info: SimulationInfo, signal?: AbortSignal | undefined): Promise { - throw new Error('Method not implemented.'); + const { jobId } = info; + + if (this.workers.hasOwnProperty(jobId)) { + this.workers[jobId].markSafeForTermination(); + delete this.workers[jobId]; + } + + return Promise.resolve(); } } From 8c07156a3054c606efc9b9c1e4622849498d0ff0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81uaksz=20Kwinta?= Date: Fri, 19 Dec 2025 11:17:28 +0100 Subject: [PATCH 2/4] Fix dissappeering of simulation info after canceling --- src/Geant4Worker/Geant4Worker.ts | 1 + src/services/Geant4LocalWorkerSimulationService.ts | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Geant4Worker/Geant4Worker.ts b/src/Geant4Worker/Geant4Worker.ts index 7f148bf95..09cc1ff1c 100644 --- a/src/Geant4Worker/Geant4Worker.ts +++ b/src/Geant4Worker/Geant4Worker.ts @@ -164,6 +164,7 @@ export default class Geant4Worker { this.worker = undefined; this.isInitialized = false; this.depsLoaded = false; + this.state = StatusState.CANCELED; } async loadDeps() { diff --git a/src/services/Geant4LocalWorkerSimulationService.ts b/src/services/Geant4LocalWorkerSimulationService.ts index 7f20bb437..77be00fd3 100644 --- a/src/services/Geant4LocalWorkerSimulationService.ts +++ b/src/services/Geant4LocalWorkerSimulationService.ts @@ -540,7 +540,6 @@ export default class Geant4LocalWorkerSimulationService implements SimulationSer if (this.workers.hasOwnProperty(jobId)) { this.workers[jobId].markSafeForTermination(); - delete this.workers[jobId]; } return Promise.resolve(); From 0348bafe0c5d92a54709570728c5e22c8ec7c955 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81uaksz=20Kwinta?= Date: Fri, 19 Dec 2025 20:58:36 +0100 Subject: [PATCH 3/4] Revert converter --- src/libs/converter | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/converter b/src/libs/converter index 56ce7c213..3c4c47f5a 160000 --- a/src/libs/converter +++ b/src/libs/converter @@ -1 +1 @@ -Subproject commit 56ce7c213e1711644a4caf7a13c157e5303db182 +Subproject commit 3c4c47f5a6d2b88e6f3021ba10bbaab36f7b3e01 From 15a8c5005ea6f5c73bcdf8878af693423e7f7ebb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81uaksz=20Kwinta?= Date: Sat, 20 Dec 2025 00:14:18 +0100 Subject: [PATCH 4/4] Address @kmichalik review --- src/Geant4Worker/Geant4Worker.ts | 6 +++++- src/services/Geant4LocalWorkerSimulationService.ts | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Geant4Worker/Geant4Worker.ts b/src/Geant4Worker/Geant4Worker.ts index 09cc1ff1c..d097a39ac 100644 --- a/src/Geant4Worker/Geant4Worker.ts +++ b/src/Geant4Worker/Geant4Worker.ts @@ -154,6 +154,11 @@ export default class Geant4Worker { ); } + cancel() { + this.markSafeForTermination(); + this.state = StatusState.CANCELED; + } + markSafeForTermination() { // we can delay the call should it be needed in the future this.destroy(); @@ -164,7 +169,6 @@ export default class Geant4Worker { this.worker = undefined; this.isInitialized = false; this.depsLoaded = false; - this.state = StatusState.CANCELED; } async loadDeps() { diff --git a/src/services/Geant4LocalWorkerSimulationService.ts b/src/services/Geant4LocalWorkerSimulationService.ts index 77be00fd3..2d177d8a0 100644 --- a/src/services/Geant4LocalWorkerSimulationService.ts +++ b/src/services/Geant4LocalWorkerSimulationService.ts @@ -539,7 +539,7 @@ export default class Geant4LocalWorkerSimulationService implements SimulationSer const { jobId } = info; if (this.workers.hasOwnProperty(jobId)) { - this.workers[jobId].markSafeForTermination(); + this.workers[jobId].cancel(); } return Promise.resolve();