JavaScript is disabled on your browser.
Skip navigation links

AWS SDK for Java 1.x API Reference - 1.12.793

We announced the upcoming end-of-support for AWS SDK for Java (v1). We recommend that you migrate to AWS SDK for Java v2. For dates, additional details, and information on how to migrate, please refer to the linked announcement.
com.amazonaws.util

Class CapacityManager



  • public class CapacityManager
    extends Object 
    Manages capacity of a finite resource. Capacity can be acquired and released.
    • Constructor Summary

      Constructors
      Constructor and Description
      CapacityManager (int maxCapacity)
      Creates a CapacityManager.
    • Method Summary

      All Methods
      Modifier and Type Method and Description
      boolean acquire ()
      Attempts to acquire a single capacity unit.
      boolean acquire (int capacity)
      Attempts to acquire a given amount of capacity.
      int availableCapacity ()
      Returns the currently available capacity.
      int consumedCapacity ()
      Returns the currently consumed capacity.
      void release ()
      Releases a single unit of capacity back to the pool, making it available to consumers.
      void release (int capacity)
      Releases a given amount of capacity back to the pool, making it available to consumers.
    • Constructor Detail

      • CapacityManager

        public CapacityManager(int maxCapacity)
        Creates a CapacityManager.
        Parameters:
        maxCapacity - maximum capacity of this resource. available capacity will initially be set to this value. if a negative value is provided the capacity manager will operate in a no-op passthrough mode in which all acquire calls will return true.
    • Method Detail

      • acquire

        public boolean acquire()
        Attempts to acquire a single capacity unit. If acquired, capacity will be consumed from the available pool.
        Returns:
        true if capacity can be acquired, false if not
      • acquire

        public boolean acquire(int capacity)
        Attempts to acquire a given amount of capacity. If acquired, capacity will be consumed from the available pool.
        Parameters:
        capacity - capacity to acquire
        Returns:
        true if capacity can be acquired, false if not
        Throws:
        IllegalArgumentException - if given capacity is negative
      • release

        public void release()
        Releases a single unit of capacity back to the pool, making it available to consumers.
      • release

        public void release(int capacity)
        Releases a given amount of capacity back to the pool, making it available to consumers.
        Parameters:
        capacity - capacity to release
        Throws:
        IllegalArgumentException - if given capacity is negative
      • consumedCapacity

        public int consumedCapacity()
        Returns the currently consumed capacity.
        Returns:
        consumed capacity
      • availableCapacity

        public int availableCapacity()
        Returns the currently available capacity.
        Returns:
        available capacity
Skip navigation links

AltStyle によって変換されたページ (->オリジナル) /