Class ResizableSemaphore

    • Constructor Detail

      • ResizableSemaphore

        public ResizableSemaphore​(int permits,
                                  boolean fair)
        Creates a ResizableSemaphore with the given number of permits and the given fairness setting.
        Parameters:
        permits - the initial number of permits available. This value may be negative, in which case releases must occur before any acquires will be granted.
        fair - true if this semaphore will guarantee first-in first-out granting of permits under contention, else false
      • ResizableSemaphore

        public ResizableSemaphore​(int permits)
        Creates a ResizableSemaphore with the given number of permits and nonfair fairness setting.
        Parameters:
        permits - the initial number of permits available. This value may be negative, in which case releases must occur before any acquires will be granted.
    • Method Detail

      • reducePermits

        protected void reducePermits​(int reduction)
        Overridden method to stop it being protected. Decrease the number of available permits by the amount in the supplied argument.
        Overrides:
        reducePermits in class Semaphore
        Parameters:
        reduction -
      • increasePermits

        public void increasePermits​(int increase)
        Increase the number of available permits by the amount in the supplied argument.
        Parameters:
        increase - The number of permits to add.