def timeToNextArrival()

in src/main/scala/com/twitter/iago/util/InfiniteRampPoissonProcess.scala [87:106]


  def timeToNextArrival(): Duration = {
    totalArrivals += 1
    if (totalArrivals >= nextStepPoint.toInt) {
      // Compute when to next update rate (numerically integrate number of arrivals over the next ms).
      // Loops handles the case where step points increase more quickly than arrivals.
      while (totalArrivals >= nextStepPoint.toInt) {
        nextStepPoint += increaseStepPoint
        currentArrivalsPerSecond += stepPerMilli
      }

      // clamp rate to final arrival rate and only update distribution if it has changed (by 1+ RPS)
      val mean = 1000000000.0 / currentRate
      if (dist.getMean != mean) {
        dist = new ExponentialDistributionImpl(mean)
      }
    }

    val nanosToNextArrival = dist.inverseCumulativeProbability(rand.nextDouble())
    Duration(nanosToNextArrival.toLong, TimeUnit.NANOSECONDS)
  }