| 1 | import { WorkerWorld } from "./workerWorld.js"; |
| 2 | |
| 3 | export class InProcessWorker |
| 4 | { |
| 5 | constructor (workerId) |
| 6 | { |
| 7 | this.workerId = workerId; |
| 8 | this.world = new WorkerWorld(workerId); |
| 9 | } |
| 10 | |
| 11 | call (message) |
| 12 | { |
| 13 | const result = this.world.handle(structuredClone(message)); |
| 14 | return result === undefined ? undefined : structuredClone(result); |
| 15 | } |
| 16 | |
| 17 | async terminate () |
| 18 | { |
| 19 | } |
| 20 | } |