-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve performance for ConstituentDependency, tighter double-notific…
…ation testing, MergeListener paranoia, SwapListener swapping (#3142) * Tighten expectations for notification delivery in BaseTable * Unit test to reproduce theorized dependency error (if we disable the code that guards against it) * Optimizations to ConstituentDependency: avoid concurrent checks, record lowest unsatisfied constituent position to resume from * MergedListener (including the multiplexing one for SyncTableFilter) changed to be a little more cautious about double-notifies, and support next-cycle error notification when needed * Get rid of ShiftObliviousSwapListener * Switch from SwapListener as a permanent link in the DAG to a temporary one which is always eliminated by the end of the instantiation cycle * Fix some missing destroy implementations and parent manage calls for "exotic" listeners
- Loading branch information
Showing
34 changed files
with
563 additions
and
431 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
Base/src/main/java/io/deephaven/base/reference/SwappableDelegatingReference.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/** | ||
* Copyright (c) 2016-2022 Deephaven Data Labs and Patent Pending | ||
*/ | ||
package io.deephaven.base.reference; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.Objects; | ||
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; | ||
|
||
/** | ||
* {@link SimpleReference} implementation that delegates to an internal {@link SimpleReference} which can be replaced | ||
* using the {@link #swapDelegate(SimpleReference, SimpleReference)} method. | ||
*/ | ||
public class SwappableDelegatingReference<T> implements SimpleReference<T> { | ||
|
||
@SuppressWarnings("rawtypes") | ||
private static final AtomicReferenceFieldUpdater<SwappableDelegatingReference, SimpleReference> DELEGATE_UPDATER = | ||
AtomicReferenceFieldUpdater.newUpdater( | ||
SwappableDelegatingReference.class, SimpleReference.class, "delegate"); | ||
|
||
private volatile SimpleReference<T> delegate; | ||
|
||
public SwappableDelegatingReference(@NotNull final SimpleReference<T> delegate) { | ||
this.delegate = Objects.requireNonNull(delegate); | ||
} | ||
|
||
/** | ||
* Swap the delegate assigned to this SwappableDelegatingReference. | ||
* | ||
* @param oldDelegate The delegate to swap out | ||
* @param newDelegate The delegate to swap in | ||
* @throws IllegalArgumentException if {@code oldDelegate} is not the current delegate value | ||
*/ | ||
public void swapDelegate( | ||
@NotNull final SimpleReference<T> oldDelegate, | ||
@NotNull final SimpleReference<T> newDelegate) { | ||
if (!DELEGATE_UPDATER.compareAndSet(this, oldDelegate, newDelegate)) { | ||
throw new IllegalArgumentException( | ||
"Previous delegate mismatch: found " + delegate + ", expected " + oldDelegate); | ||
} | ||
} | ||
|
||
@Override | ||
public T get() { | ||
return delegate.get(); | ||
} | ||
|
||
@Override | ||
public void clear() { | ||
delegate.clear(); | ||
delegate = null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.