Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: make DeferredColumnRegionBase more efficient wrt volatile #6574

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import io.deephaven.base.verify.Require;
import io.deephaven.chunk.attributes.Any;
import io.deephaven.engine.table.SharedContext;
import io.deephaven.chunk.*;
import io.deephaven.engine.rowset.RowSequence;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -33,39 +32,33 @@ public abstract class DeferredColumnRegionBase<ATTR extends Any, REGION_TYPE ext
public void invalidate() {
super.invalidate();
synchronized (this) {
if (resultRegion != null) {
resultRegion.invalidate();
REGION_TYPE localResultRegion;
if ((localResultRegion = resultRegion) != null) {
localResultRegion.invalidate();
}
}
}

@Override
public final REGION_TYPE getResultRegion() {
if (resultRegion == null) {
REGION_TYPE localResultRegion;
if ((localResultRegion = resultRegion) == null) {
synchronized (this) {
if (resultRegion == null) {
resultRegion = Require.neqNull(resultRegionFactory.get(), "resultRegionFactory.get()");
if ((localResultRegion = resultRegion) == null) {
resultRegion =
localResultRegion = Require.neqNull(resultRegionFactory.get(), "resultRegionFactory.get()");
resultRegionFactory = null;
}
}
}
return resultRegion;
}

/**
* Get the result region if it has already been supplied (because of a call to {@link #getResultRegion()}).
*
* @return The result region
*/
private REGION_TYPE getResultRegionIfSupplied() {
return resultRegion;
return localResultRegion;
}

@Override
@OverridingMethodsMustInvokeSuper
public void releaseCachedResources() {
DeferredColumnRegion.super.releaseCachedResources();
final REGION_TYPE localResultRegion = getResultRegionIfSupplied();
final REGION_TYPE localResultRegion = resultRegion;
if (localResultRegion != null) {
localResultRegion.releaseCachedResources();
}
Expand Down