private double doAcquire(double permitsToAcquire,double currentTime){
  while (true) {
    readRate.lock();
    try {
      double permitReleaseRate=this.permitsPerSecond;
      double clockDelta=permitsToAcquire / permitReleaseRate;
      double lowestAllowedClock=currentTime - backlogSize;
      double currentClock=clock.get();
      double nextClock=currentClock + clockDelta;
      if (nextClock < lowestAllowedClock)       nextClock=lowestAllowedClock;
      if (clock.compareAndSet(currentClock,nextClock)) {
        if (nextClock > currentTime)         return permitReleaseRate * (nextClock - currentTime);
 else         return 0;
      }
    }
  finally {
      readRate.unlock();
    }
  }
}

private double doAcquire ( double permitsToAcquire , double currentTime ) { while ( true ) { readRate . lock ( ) ; try { double permitReleaseRate = this . permitsPerSecond ; double clockDelta = permitsToAcquire / permitReleaseRate ; double lowestAllowedClock = currentTime - backlogSize ; double currentClock = clock . get ( ) ; double nextClock = currentClock + clockDelta ; if ( nextClock < lowestAllowedClock ) nextClock = lowestAllowedClock ; if ( clock . compareAndSet ( currentClock , nextClock ) ) { if ( nextClock > currentTime ) return permitReleaseRate * ( nextClock - currentTime ) ; else return 0 ; } } finally { readRate . unlock ( ) ; } } }
updates the clock based on the number of permits requested
