static long getAndSub ( RingBuffer . Sequence sequence , long toSub ) { long r , u ; do { r = sequence . getAsLong ( ) ; if ( r == 0 || r == Long . MAX_VALUE ) { return r ; } u = Operators . subOrZero ( r , toSub ) ; } while ( ! sequence . compareAndSet ( r , u ) ) ; return r ; }
Concurrent subtraction bound to 0 and Long . MAX_VALUE . Any concurrent write will happen before this operation .