namespace com.sleepycat.je.log;

class LogBufferPool
{
  depend com.sleepycat.je.latch.LatchSupport;
  depend com.sleepycat.je.latch.Latch;
    private Latch bufferPoolLatch;

    after Label485: LogBufferPool(FileManager , EnvironmentImpl ) {
	bufferPoolLatch = LatchSupport.makeLatch(DEBUG_NAME + "_FullLatch", envImpl);
	//original(envImpl);
    }

    /** 
     * Initialize the pool at construction time and when the cache is resized. This method is called after the memory budget has been calculated.
     */
    after reset(DbConfigManager )  {
	//original(configManager);
	bufferPoolLatch.release();
    }

    after Label486: reset(DbConfigManager ) {
	bufferPoolLatch.acquire();
	//original();
    }

    after Label487_1:writeBufferToFile(int ) {

//	try { //original(bufferSize, latchedBuffer);} finally {
	    if (latchedBuffer != null) {
		latchedBuffer.release();
	    }
//	}
    }

    after Label488:writeBufferToFile(int ) {

	currentWriteBuffer.latchForWrite();
	//original();
    }

    protected LogBuffer hook489: getReadBuffer(long ) {
	bufferPoolLatch.acquire();
//	try {foundBuffer = //original(lsn, foundBuffer);} finally {	    bufferPoolLatch.releaseIfOwner();}
	//return foundBuffer;
    }

    protected LogBuffer Label489_1: getReadBuffer(long ) {

	    bufferPoolLatch.releaseIfOwner();
	//return foundBuffer;
    }


    after Label490: writeBufferToFile(int ) { 
	bufferPoolLatch.release();
	//original();
    }

    after Label491: writeBufferToFile(int ) { 
	bufferPoolLatch.acquire();
	//original();
    }

    after Label492: writeBufferToFile(int ) { 
	latchedBuffer.release();
	//original(latchedBuffer);
    }

    after Label493: writeBufferToFile(int ) { 
//	try {	    //original(nextToUse);} finally {
	    bufferPoolLatch.releaseIfOwner();
	//}
    }

    after Label494: writeBufferToFile(int ) { 
	latchedBuffer.release();
	//original(latchedBuffer);
    }

    after Label495: writeBufferToFile(int ) { 

	bufferPoolLatch.acquire();
	//original();
    }

}
