Skip to content

Commit 682852f

Browse files
committed
Make LivenessScopeStack play better with other LivenessManager implementations, not just LivenessScope
1 parent 600178b commit 682852f

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

engine/updategraph/src/main/java/io/deephaven/engine/liveness/LivenessScopeStack.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class LivenessScopeStack {
2828
private static final ThreadLocal<LivenessManager> THREAD_BASE_MANAGER =
2929
ThreadLocal.withInitial(PermanentLivenessManager::new);
3030

31-
private final Deque<LivenessScope> stack = new ArrayDeque<>();
31+
private final Deque<LivenessManager> stack = new ArrayDeque<>();
3232

3333
private LivenessScopeStack() {}
3434

@@ -38,7 +38,7 @@ private LivenessScopeStack() {}
3838
*
3939
* @param scope The scope
4040
*/
41-
public static void push(@NotNull final LivenessScope scope) {
41+
public static void push(@NotNull final LivenessManager scope) {
4242
THREAD_STACK.get().pushInternal(scope);
4343
}
4444

@@ -50,7 +50,7 @@ public static void push(@NotNull final LivenessScope scope) {
5050
*
5151
* @param scope The scope
5252
*/
53-
public static void pop(@NotNull final LivenessScope scope) {
53+
public static void pop(@NotNull final LivenessManager scope) {
5454
THREAD_STACK.get().popInternal(scope);
5555
}
5656

@@ -76,11 +76,11 @@ public static LivenessManager peek() {
7676
*
7777
* @param scope The scope
7878
* @param releaseOnClose Whether the scope should be released when the result is closed
79-
* @return A {@link SafeCloseable} whose {@link SafeCloseable#close()} method invokes {@link #pop(LivenessScope)}
79+
* @return A {@link SafeCloseable} whose {@link SafeCloseable#close()} method invokes {@link #pop(LivenessManager)}
8080
* for the scope (followed by {@link LivenessScope#release()} if releaseOnClose is true)
8181
*/
8282
@NotNull
83-
public static SafeCloseable open(@NotNull final LivenessScope scope, final boolean releaseOnClose) {
83+
public static SafeCloseable open(@NotNull final ReleasableLivenessManager scope, final boolean releaseOnClose) {
8484
push(scope);
8585
return releaseOnClose ? new PopAndReleaseOnClose(scope) : new PopOnClose(scope);
8686
}
@@ -93,7 +93,7 @@ public static SafeCloseable open(@NotNull final LivenessScope scope, final boole
9393
* This is useful enclosing a series of query engine actions whose results must be explicitly retained externally in
9494
* order to preserve liveness.
9595
*
96-
* @return A {@link SafeCloseable} whose {@link SafeCloseable#close()} method invokes {@link #pop(LivenessScope)}
96+
* @return A {@link SafeCloseable} whose {@link SafeCloseable#close()} method invokes {@link #pop(LivenessManager)}
9797
* for the scope, followed by {@link LivenessScope#release()}
9898
*/
9999
@NotNull
@@ -103,18 +103,18 @@ public static SafeCloseable open() {
103103
return new PopAndReleaseOnClose(scope);
104104
}
105105

106-
private void pushInternal(@NotNull final LivenessScope scope) {
106+
private void pushInternal(@NotNull final LivenessManager scope) {
107107
if (Liveness.DEBUG_MODE_ENABLED) {
108108
Liveness.log.info().append("LivenessDebug: Pushing scope ").append(Utils.REFERENT_FORMATTER, scope).endl();
109109
}
110110
stack.push(scope);
111111
}
112112

113-
private void popInternal(@NotNull final LivenessScope scope) {
113+
private void popInternal(@NotNull final LivenessManager scope) {
114114
if (Liveness.DEBUG_MODE_ENABLED) {
115115
Liveness.log.info().append("LivenessDebug: Popping scope ").append(Utils.REFERENT_FORMATTER, scope).endl();
116116
}
117-
final LivenessScope peeked = stack.peekFirst();
117+
final LivenessManager peeked = stack.peekFirst();
118118
if (peeked != scope) {
119119
throw new IllegalStateException(
120120
"Caller requested to pop " + scope + " but the top of the scope stack is " + peeked);
@@ -124,15 +124,15 @@ private void popInternal(@NotNull final LivenessScope scope) {
124124

125125
@NotNull
126126
private LivenessManager peekInternal() {
127-
final LivenessScope peeked = stack.peekFirst();
127+
final LivenessManager peeked = stack.peekFirst();
128128
return peeked != null ? peeked : THREAD_BASE_MANAGER.get();
129129
}
130130

131131
private static final class PopOnClose implements SafeCloseable {
132132

133-
private final LivenessScope scope;
133+
private final LivenessManager scope;
134134

135-
private PopOnClose(@NotNull final LivenessScope scope) {
135+
private PopOnClose(@NotNull final LivenessManager scope) {
136136
this.scope = scope;
137137
}
138138

@@ -144,9 +144,9 @@ public void close() {
144144

145145
private static final class PopAndReleaseOnClose implements SafeCloseable {
146146

147-
private final LivenessScope scope;
147+
private final ReleasableLivenessManager scope;
148148

149-
private PopAndReleaseOnClose(@NotNull final LivenessScope scope) {
149+
private PopAndReleaseOnClose(@NotNull final ReleasableLivenessManager scope) {
150150
this.scope = scope;
151151
}
152152

0 commit comments

Comments
 (0)