WXL
3 天以前 9bce51f651aad297ef9eb6df832bfdaf1de05d84
node_modules/webpack/lib/util/Semaphore.js
@@ -5,9 +5,14 @@
"use strict";
/**
 * Simple counting semaphore used to limit how many asynchronous tasks may run
 * concurrently.
 */
class Semaphore {
   /**
    * Creates an instance of Semaphore.
    * Initializes the semaphore with the number of permits that may be held at
    * the same time.
    * @param {number} available the amount available number of "tasks"
    * in the Semaphore
    */
@@ -20,6 +25,8 @@
   }
   /**
    * 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}
    */
@@ -32,6 +39,9 @@
      }
   }
   /**
    * Releases a permit and schedules the next waiting callback, if any.
    */
   release() {
      this.available++;
      if (this.waiters.length > 0) {
@@ -39,6 +49,9 @@
      }
   }
   /**
    * Drains the next waiting callback after a permit becomes available.
    */
   _continue() {
      if (this.available > 0 && this.waiters.length > 0) {
         this.available--;