@ Override public void recycle ( MemorySegment segment ) { int numAddedBuffers ; synchronized ( bufferQueue ) { // Similar to notifyBufferAvailable(), make sure that we never add a buffer // after releaseAllResources() released all buffers (see below for details). if ( isReleased . get ( ) ) { try { inputGate . returnExclusiveSegments ( Collections . singletonList ( segment ) ) ; return ; } catch ( Throwable t ) { ExceptionUtils . rethrow ( t ) ; } } numAddedBuffers = bufferQueue . addExclusiveBuffer ( new NetworkBuffer ( segment , this ) , numRequiredBuffers ) ; } if ( numAddedBuffers > 0 && unannouncedCredit . getAndAdd ( numAddedBuffers ) == 0 ) { notifyCreditAvailable ( ) ; } }
Exclusive buffer is recycled to this input channel directly and it may trigger return extra floating buffer and notify increased credit to the producer .