Skip to content

Commit

Permalink
Extract method to help inlining, maybe
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisvest committed Jan 20, 2016
1 parent 9bad0fe commit 7f536b0
Showing 1 changed file with 27 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,32 +86,37 @@ public boolean shouldRetry() throws IOException
boolean needsRetry = !page.validateReadLock( lockStamp );
if ( needsRetry )
{
setOffset( 0 );
lockStamp = page.tryOptimisticReadLock();
// The page might have been evicted while we held the optimistic
// read lock, so we need to check with page.pin that this is still
// the page we're actually interested in:
if ( !page.isBoundTo( pagedFile.swapper, currentPageId ) )
{
// This is no longer the page we're interested in, so we have
// to redo the pinning.
// This might in turn lead to a new optimistic lock on a
// different page if someone else has taken the page fault for
// us. If nobody has done that, we'll take the page fault
// ourselves, and in that case we'll end up with first an exclusive
// lock during the faulting, and then an optimistic read lock once the
// fault itself is over.
// First, forget about this page in case pin() throws and the cursor
// is closed; we don't want unpinCurrentPage() to try unlocking
// this page.
page = null;
// Then try pin again.
pin( currentPageId, false );
}
startRetry();
}
return needsRetry;
}

private void startRetry() throws IOException
{
setOffset( 0 );
lockStamp = page.tryOptimisticReadLock();
// The page might have been evicted while we held the optimistic
// read lock, so we need to check with page.pin that this is still
// the page we're actually interested in:
if ( !page.isBoundTo( pagedFile.swapper, currentPageId ) )
{
// This is no longer the page we're interested in, so we have
// to redo the pinning.
// This might in turn lead to a new optimistic lock on a
// different page if someone else has taken the page fault for
// us. If nobody has done that, we'll take the page fault
// ourselves, and in that case we'll end up with first an exclusive
// lock during the faulting, and then an optimistic read lock once the
// fault itself is over.
// First, forget about this page in case pin() throws and the cursor
// is closed; we don't want unpinCurrentPage() to try unlocking
// this page.
page = null;
// Then try pin again.
pin( currentPageId, false );
}
}

@Override
public void putByte( byte value )
{
Expand Down

0 comments on commit 7f536b0

Please sign in to comment.