Class AllocationStatistic

java.lang.Object
eu.cloudnetservice.driver.impl.network.object.data.AllocationStatistic

final class AllocationStatistic extends Object
A holder for a statistic about the amount of bytes being allocated during another call. This can be used to reduce the amount of buffer resizes being necessary to write data.
Since:
4.0
  • Field Details

    • STATISTIC_HOLDER_UPDATER

      private static final VarHandle STATISTIC_HOLDER_UPDATER
    • statisticHolder

      private long[] statisticHolder
  • Constructor Details

    • AllocationStatistic

      AllocationStatistic()
  • Method Details

    • add

      public void add(int allocatedBytes)
      Adds the given amount of bytes from an allocation run into the statistic. If the given allocated bytes are negative or a long overflow would occur adding it, the call is silently ignored.
      Parameters:
      allocatedBytes - the bytes that were allocated during a serialization.
    • average

      public int average()
      Get the average amount of bytes being allocated in the past allocation runs.
      Returns:
      the average amount of bytes being allocated in the past allocation runs.
      Throws:
      ArithmeticException - if the allocation byte average overflows an int.