public long get ( ) { long now = CurrentTime . currentTime ( ) / 1000 ; long oldSequence ; long newSequence ; do { oldSequence = _sequence . get ( ) ; long oldTime = oldSequence >>> _timeOffset ; if ( oldTime != now ) { newSequence = ( ( now << _timeOffset ) + ( randomLong ( ) & _sequenceRandomMask ) ) ; } else { // relatively prime increment will use the whole sequence space newSequence = oldSequence + _sequenceIncrement ; } } while ( ! _sequence . compareAndSet ( oldSequence , newSequence ) ) ; long id = ( ( now << _timeOffset ) | _node | ( newSequence & _sequenceMask ) ) ; return id ; }
Returns the next id .