private void decrementSizeAndCount ( E record ) { // Update the count for atomically counted queues. if ( atomicallyCounted ) { count . decrementAndGet ( ) ; } // Update the size for sizeable elements and sizeable queues. if ( sizeable && ( record instanceof Sizeable ) ) { long recordSize = - ( ( Sizeable ) record ) . sizeof ( ) ; long oldSize = dataSize . getAndAdd ( recordSize ) ; long newSize = oldSize + recordSize ; signalOnSizeThresholdCrossing ( oldSize , newSize ) ; } else if ( sizeable ) { long oldSize = dataSize . getAndDecrement ( ) ; long newSize = oldSize - 1 ; signalOnSizeThresholdCrossing ( oldSize , newSize ) ; } }
Atomically subtracts from the size and count if the queue is running in atomic counting mode or sizeable mode and the element is sizeable .