MCPcopy
hub / github.com/webpack/webpack / acquire

Method acquire

lib/util/Semaphore.js:34–41  ·  view source on GitHub ↗

* Acquires a permit for the callback immediately when one is available or * queues the callback until another task releases its permit. * @param {() => void} callback function block to capture and run * @returns {void}

(callback)

Source from the content-addressed store, hash-verified

32 * @returns {void}
33 */
34 acquire(callback) {
35 if (this.available > 0) {
36 this.available--;
37 callback();
38 } else {
39 this.waiters.push(callback);
40 }
41 }
42
43 /**
44 * Releases a permit and schedules the next waiting callback, if any.

Callers 2

_analyseModuleMethod · 0.80

Calls 2

callbackFunction · 0.50
pushMethod · 0.45

Tested by

no test coverage detected