()
| 170 | } |
| 171 | |
| 172 | async function runWorker() { |
| 173 | while (running) { |
| 174 | const currentStatus = Atomics.load(view, 0); |
| 175 | |
| 176 | if (currentStatus & 0b100) { |
| 177 | running = false; |
| 178 | break; |
| 179 | } |
| 180 | |
| 181 | if ((currentStatus & 0b001) && !processing) { |
| 182 | processing = true; |
| 183 | |
| 184 | await processRequestAsync(); |
| 185 | |
| 186 | } else if (!processing) { |
| 187 | Atomics.wait(view, 0, currentStatus); |
| 188 | } |
| 189 | |
| 190 | await new Promise(resolve => setTimeout(resolve, 1)); |
| 191 | } |
| 192 | |
| 193 | log('info', '[Worker] Exiting'); |
| 194 | } |
| 195 | |
| 196 | runWorker().then(() => { |
| 197 | process.exit(0); |
no test coverage detected