Skip to content

Commit

Permalink
More descriptive variable names in PageList.
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisvest committed Jun 14, 2018
1 parent 93061e8 commit e0e602b
Showing 1 changed file with 8 additions and 8 deletions.
Expand Up @@ -328,17 +328,17 @@ public void incrementUsage( long pageRef )
{ {
// This is intentionally left benignly racy for performance. // This is intentionally left benignly racy for performance.
long address = offFilePageId( pageRef ); long address = offFilePageId( pageRef );
long v = UnsafeUtil.getLongVolatile( address ); long value = UnsafeUtil.getLongVolatile( address );
long usage = v & MASK_USAGE_COUNT; long usage = value & MASK_USAGE_COUNT;
if ( usage < 4 ) // avoid cache sloshing by not doing a write if counter is already maxed out if ( usage < 4 ) // avoid cache sloshing by not doing a write if counter is already maxed out
{ {
long u = v + 1; long update = value + 1;
// Use compareAndSwapLong to only actually store the updated count if nothing else changed // Use compareAndSwapLong to only actually store the updated count if nothing else changed
// in this word-line. The word-line is shared with the file page id, and the swapper id. // in this word-line. The word-line is shared with the file page id, and the swapper id.
// Those fields are updated under guard of the exclusive lock, but we *might* race with // Those fields are updated under guard of the exclusive lock, but we *might* race with
// that here, and in that case we would never want a usage counter update to clobber a page // that here, and in that case we would never want a usage counter update to clobber a page
// binding update. // binding update.
UnsafeUtil.compareAndSwapLong( null, address, v, u ); UnsafeUtil.compareAndSwapLong( null, address, value, update );
} }
} }


Expand All @@ -349,13 +349,13 @@ public boolean decrementUsage( long pageRef )
{ {
// This is intentionally left benignly racy for performance. // This is intentionally left benignly racy for performance.
long address = offFilePageId( pageRef ); long address = offFilePageId( pageRef );
long v = UnsafeUtil.getLongVolatile( address ); long value = UnsafeUtil.getLongVolatile( address );
long usage = v & MASK_USAGE_COUNT; long usage = value & MASK_USAGE_COUNT;
if ( usage > 0 ) if ( usage > 0 )
{ {
long u = v - 1; long update = value - 1;
// See `incrementUsage` about why we use `compareAndSwapLong`. // See `incrementUsage` about why we use `compareAndSwapLong`.
UnsafeUtil.compareAndSwapLong( null, address, v, u ); UnsafeUtil.compareAndSwapLong( null, address, value, update );
} }
return usage <= 1; return usage <= 1;
} }
Expand Down

0 comments on commit e0e602b

Please sign in to comment.