public static < T > long produced ( AtomicLongFieldUpdater < T > updater , T instance , long toSub ) { long r , u ; do { r = updater . get ( instance ) ; if ( r == 0 || r == Long . MAX_VALUE ) { return r ; } u = subOrZero ( r , toSub ) ; } while ( ! updater . compareAndSet ( instance , r , u ) ) ; return u ; }
Concurrent subtraction bound to 0 mostly used to decrement a request tracker by the amount produced by the operator . Any concurrent write will happen before this operation .