MCPcopy Index your code
hub / github.com/nodejs/node / asyncRefillRandomIntCache

Function asyncRefillRandomIntCache

lib/internal/crypto/random.js:281–306  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

279}
280
281function 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
309function onJobDone(buf, callback, error) {

Callers 1

randomIntFunction · 0.85

Calls 3

randomFillFunction · 0.85
randomIntFunction · 0.85
callbackMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…