protected long findUnusedTimestamp(final long commitTime,final long nextCommitTime,final long timeout,final TimeUnit unit) throws InterruptedException, TimeoutException {
  final long begin=System.nanoTime();
  final long nanos=unit.toNanos(timeout);
  long remaining=nanos;
  while (remaining >= 0) {
    for (long t=commitTime; t < nextCommitTime; t++) {
      if (activeTx.containsKey(t) || activeTx.containsKey(-t)) {
        continue;
      }
      return t;
    }
    remaining=nanos - (System.nanoTime() - begin);
    if (!txDeactivate.await(remaining,TimeUnit.NANOSECONDS)) {
      throw new TimeoutException();
    }
    remaining=nanos - (System.nanoTime() - begin);
  }
  throw new TimeoutException();
}

protected long findUnusedTimestamp ( final long commitTime , final long nextCommitTime , final long timeout , final TimeUnit unit ) throws InterruptedException , TimeoutException { final long begin = System . nanoTime ( ) ; final long nanos = unit . toNanos ( timeout ) ; long remaining = nanos ; while ( remaining >= 0 ) { for ( long t = commitTime ; t < nextCommitTime ; t ++ ) { if ( activeTx . containsKey ( t ) || activeTx . containsKey ( - t ) ) { continue ; } return t ; } remaining = nanos - ( System . nanoTime ( ) - begin ) ; if ( ! txDeactivate . await ( remaining , TimeUnit . NANOSECONDS ) ) { throw new TimeoutException ( ) ; } remaining = nanos - ( System . nanoTime ( ) - begin ) ; } throw new TimeoutException ( ) ; }
find a valid , unused timestamp . < p > note : any timestamp in the half - open range [ committime : nextcommittime ) may be assigned as all such timestamps will read from the commit point associated with [ committime ] .
