Class VMAHeapBudget

java.lang.Object
com.io7m.jcoronado.vma.VMAHeapBudget
All Implemented Interfaces:
VMAHeapBudgetType

public final class VMAHeapBudget extends Object implements VMAHeapBudgetType
The current memory usage and recommended budget for a single memory heap.
See Also:
  • "VmaBudget"
  • Method Details

    • usage

      public long usage()
      Specified by:
      usage in interface VMAHeapBudgetType
      Returns:
      The current memory usage of the heap, in bytes.
    • budget

      public long budget()
      Specified by:
      budget in interface VMAHeapBudgetType
      Returns:
      The recommended memory budget for the heap, in bytes. Keeping usage at or below the budget avoids the driver stalling or returning VK_ERROR_OUT_OF_DEVICE_MEMORY.
    • withUsage

      public final VMAHeapBudget withUsage(long value)
      Copy the current immutable object by setting a value for the usage attribute. A value equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for usage
      Returns:
      A modified copy or the this object
    • withBudget

      public final VMAHeapBudget withBudget(long value)
      Copy the current immutable object by setting a value for the budget attribute. A value equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for budget
      Returns:
      A modified copy or the this object
    • equals

      public boolean equals(Object another)
      This instance is equal to all instances of VMAHeapBudget that have equal attribute values.
      Overrides:
      equals in class Object
      Returns:
      true if this is equal to another instance
    • hashCode

      public int hashCode()
      Computes a hash code from attributes: usage, budget.
      Overrides:
      hashCode in class Object
      Returns:
      hashCode value
    • toString

      public String toString()
      Prints the immutable value VMAHeapBudget with attribute values.
      Overrides:
      toString in class Object
      Returns:
      A string representation of the value
    • copyOf

      public static VMAHeapBudget copyOf(VMAHeapBudgetType instance)
      Creates an immutable copy of a VMAHeapBudgetType value. Uses accessors to get values to initialize the new immutable instance. If an instance is already immutable, it is returned as is.
      Parameters:
      instance - The instance to copy
      Returns:
      A copied immutable VMAHeapBudget instance
    • builder

      public static VMAHeapBudget.Builder builder()
      Creates a builder for VMAHeapBudget.
      VMAHeapBudget.builder()
         .setUsage(long) // required usage
         .setBudget(long) // required budget
         .build();
      
      Returns:
      A new VMAHeapBudget builder