(worker: WorkerType)
| 107 | } |
| 108 | |
| 109 | function createTerminator(worker: WorkerType): { termination: Promise<void>, terminate: () => Promise<void> } { |
| 110 | const [termination, resolver] = createPromiseWithResolver<void>() |
| 111 | const terminate = async () => { |
| 112 | debugThreadUtils("Terminating worker") |
| 113 | // Newer versions of worker_threads workers return a promise |
| 114 | await worker.terminate() |
| 115 | resolver() |
| 116 | } |
| 117 | return { terminate, termination } |
| 118 | } |
| 119 | |
| 120 | function setPrivateThreadProps<T>(raw: T, worker: WorkerType, workerEvents: Observable<WorkerEvent>, terminate: () => Promise<void>): T & PrivateThreadProps { |
| 121 | const workerErrors = workerEvents |
no test coverage detected