Class LivenessScopeStack
Support for a thread-local stack of LivenessScopes to allow the preferred programming model for scoping
of LivenessArtifacts.
Instances expect to be used on exactly one thread, and hence do not take any measures to ensure thread safety.
-
Method Summary
Modifier and TypeMethodDescriptionstatic SafeCloseableopen()Push an anonymous scope onto the scope stack, and get anSafeCloseablethat pops it and thenLivenessScope.release()s it.static SafeCloseableopen(LivenessScope scope, boolean releaseOnClose) Push a scope onto the scope stack, and get anSafeCloseablethat pops it.static LivenessManagerpeek()Get the scope at the top of the current thread's scope stack, or the base manager if no scopes have been pushed but not popped on this thread.static voidpop(LivenessScope scope) Pop a scope from the current thread's scope stack.static voidpush(LivenessScope scope) Push a scope onto the current thread's scope stack.
-
Method Details
-
push
Push a scope onto the current thread's scope stack.
- Parameters:
scope- The scope
-
pop
Pop a scope from the current thread's scope stack.
Must be the current top of the stack.
- Parameters:
scope- The scope
-
peek
Get the scope at the top of the current thread's scope stack, or the base manager if no scopes have been pushed but not popped on this thread.
This method defines the manager that should be used for all new
LivenessArtifacts.- Returns:
- The current manager
-
open
Push a scope onto the scope stack, and get an
SafeCloseablethat pops it.This is useful for enclosing scope usage in a try-with-resources block.
- Parameters:
scope- The scopereleaseOnClose- Whether the scope should be released when the result is closed- Returns:
- A
SafeCloseablewhoseSafeCloseable.close()method invokespop(LivenessScope)for the scope (followed byLivenessScope.release()if releaseOnClose is true)
-
open
Push an anonymous scope onto the scope stack, and get an
SafeCloseablethat pops it and thenLivenessScope.release()s it.This is useful enclosing a series of query engine actions whose results must be explicitly retained externally in order to preserve liveness.
- Returns:
- A
SafeCloseablewhoseSafeCloseable.close()method invokespop(LivenessScope)for the scope, followed byLivenessScope.release()
-