()
| 279 | } |
| 280 | |
| 281 | function asyncRefillRandomIntCache() { |
| 282 | if (asyncCacheFillInProgress) |
| 283 | return; |
| 284 | |
| 285 | asyncCacheFillInProgress = true; |
| 286 | randomFill(randomCache, (err) => { |
| 287 | asyncCacheFillInProgress = false; |
| 288 | |
| 289 | const tasks = asyncCachePendingTasks; |
| 290 | const errorReceiver = err && ArrayPrototypeShift(tasks); |
| 291 | if (!err) |
| 292 | randomCacheOffset = 0; |
| 293 | |
| 294 | // Restart all pending tasks. If an error occurred, we only notify a single |
| 295 | // callback (errorReceiver) about it. This way, every async call to |
| 296 | // randomInt has a chance of being successful, and it avoids complex |
| 297 | // exception handling here. |
| 298 | ArrayPrototypeForEach(ArrayPrototypeSplice(tasks, 0), (task) => { |
| 299 | randomInt(task.min, task.max, task.callback); |
| 300 | }); |
| 301 | |
| 302 | // This is the only call that might throw, and is therefore done at the end. |
| 303 | if (errorReceiver) |
| 304 | errorReceiver.callback(err); |
| 305 | }); |
| 306 | } |
| 307 | |
| 308 | |
| 309 | function onJobDone(buf, callback, error) { |
no test coverage detected
searching dependent graphs…