private void repin ( ) { if ( logger . isLoggable ( Level . WARNING ) ) logger . warning ( "Tx." + txNum + " is re-pinning all buffers" ) ; try { // Copy the set of pinned buffers to avoid ConcurrentModificationException List < BlockId > blksToBeRepinned = new LinkedList < BlockId > ( ) ; Map < BlockId , Integer > pinCounts = new HashMap < BlockId , Integer > ( ) ; List < Buffer > buffersToBeUnpinned = new LinkedList < Buffer > ( ) ; // Record the buffers to be un-pinned and the blocks to be re-pinned for ( Entry < BlockId , PinnedBuffer > entry : pinnedBuffers . entrySet ( ) ) { blksToBeRepinned . add ( entry . getKey ( ) ) ; pinCounts . put ( entry . getKey ( ) , entry . getValue ( ) . pinnedCount ) ; buffersToBeUnpinned . add ( entry . getValue ( ) . buffer ) ; } // Un-pin all buffers it has for ( Buffer buf : buffersToBeUnpinned ) unpin ( buf ) ; // Wait other threads pinning blocks synchronized ( bufferPool ) { bufferPool . wait ( MAX_TIME ) ; } // Re-pin all blocks for ( BlockId blk : blksToBeRepinned ) pin ( blk ) ; } catch ( InterruptedException e ) { e . printStackTrace ( ) ; } }
Unpins all currently pinned buffers of the calling transaction and repins them .