Class LivenessScopeStack
public class LivenessScopeStack extends Object
Support for a thread-local stack of LivenessScope
s to allow the preferred programming model for scoping
of LivenessArtifact
s.
Instances expect to be used on exactly one thread, and hence do not take any measures to ensure thread safety.
-
Method Summary
Modifier and Type Method Description static SafeCloseable
open()
Push an anonymous scope onto the scope stack, and get anSafeCloseable
that pops it and thenLivenessScope.release()
s it.static SafeCloseable
open(LivenessScope scope, boolean releaseOnClose)
Push a scope onto the scope stack, and get anSafeCloseable
that pops it.static LivenessManager
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.static void
pop(LivenessScope scope)
Pop a scope from the current thread's scope stack.static void
push(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
LivenessArtifact
s.- Returns:
- The current manager
-
open
Push a scope onto the scope stack, and get an
SafeCloseable
that 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
SafeCloseable
whoseSafeCloseable.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
SafeCloseable
that 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
SafeCloseable
whoseSafeCloseable.close()
method invokespop(LivenessScope)
for the scope, followed byLivenessScope.release()
-