private boolean doTryAcquire(long permitsToAcquire){
  long currentTime=System.nanoTime();
  readRate.lock();
  try {
    while (true) {
      long nanosPerPermit=this.nanosPerPermit;
      long clockDelta=permitsToAcquire * nanosPerPermit;
      long lowestAllowedClock=currentTime - backlogSize;
      long currentClock=clock.get();
      long nextClock=currentClock + clockDelta;
      if (nextClock < lowestAllowedClock)       nextClock=lowestAllowedClock;
      if (nextClock > currentTime) {
        return false;
      }
      if (clock.compareAndSet(currentClock,nextClock)) {
        return true;
      }
    }
  }
  finally {
    readRate.unlock();
  }
}

private boolean doTryAcquire ( long permitsToAcquire ) { long currentTime = System . nanoTime ( ) ; readRate . lock ( ) ; try { while ( true ) { long nanosPerPermit = this . nanosPerPermit ; long clockDelta = permitsToAcquire * nanosPerPermit ; long lowestAllowedClock = currentTime - backlogSize ; long currentClock = clock . get ( ) ; long nextClock = currentClock + clockDelta ; if ( nextClock < lowestAllowedClock ) nextClock = lowestAllowedClock ; if ( nextClock > currentTime ) { return false ; } if ( clock . compareAndSet ( currentClock , nextClock ) ) { return true ; } } } finally { readRate . unlock ( ) ; } }
tries to acquire the specified number of permits , but only if they are immediately available
