private void releaseSession ( PooledSession session ) { Preconditions . checkNotNull ( session ) ; synchronized ( lock ) { if ( closureFuture != null ) { return ; } if ( readWaiters . size ( ) == 0 && numSessionsBeingPrepared >= readWriteWaiters . size ( ) ) { // No pending waiters if ( shouldPrepareSession ( ) ) { prepareSession ( session ) ; } else { readSessions . add ( session ) ; } } else if ( shouldUnblockReader ( ) ) { readWaiters . poll ( ) . put ( session ) ; } else { prepareSession ( session ) ; } } }
Releases a session back to the pool . This might cause one of the waiters to be unblocked .