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.
Modifier and Type | Method and Description |
---|---|
static SafeCloseable |
open()
Push an anonymous scope onto the scope stack, and get an
SafeCloseable that pops it and then
LivenessScope.release() s it. |
static SafeCloseable |
open(LivenessScope scope,
boolean releaseOnClose)
Push a scope onto the scope stack, and get an
SafeCloseable 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.
|
public static void push(@NotNull LivenessScope scope)
Push a scope onto the current thread's scope stack.
scope
- The scopepublic static void pop(@NotNull LivenessScope scope)
Pop a scope from the current thread's scope stack.
Must be the current top of the stack.
scope
- The scope@NotNull public 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.
This method defines the manager that should be used for all new LivenessArtifact
s.
@NotNull public static SafeCloseable open(@NotNull LivenessScope scope, boolean releaseOnClose)
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.
scope
- The scopereleaseOnClose
- Whether the scope should be released when the result is closedSafeCloseable
whose SafeCloseable.close()
method invokes LivenessScopeStack.pop(LivenessScope)
for the scope (followed by LivenessScope.release()
if releaseOnClose is true)@NotNull public static SafeCloseable open()
Push an anonymous scope onto the scope stack, and get an SafeCloseable
that pops it and then
LivenessScope.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.
SafeCloseable
whose SafeCloseable.close()
method invokes LivenessScopeStack.pop(LivenessScope)
for the scope, followed by LivenessScope.release()