public class Scope
extends java.lang.Object
A Scope defines a SINGLE THREADED local lifetime management context,
stored in Thread Local Storage. Scopes can be explicitly entered or exited.
User keys created by this thread are tracked, and deleted when the scope is
exited. Since enter & exit are explicit, failure to exit means the Keys
leak (there is no reliable thread-on-exit cleanup action). You must call
Scope.exit()
at some point. Only user keys & Vec keys are tracked.
Scopes support nesting. Scopes support partial cleanup: you can list Keys you'd like to keep in the exit() call. These will be "bumped up" to the higher nested scope - or escaped and become untracked at the top-level.
Constructor and Description |
---|
Scope() |
Modifier and Type | Method and Description |
---|---|
static void |
enter()
Enter a new Scope
|
static Key[] |
exit(Key... keep)
Exit the inner-most Scope, remove all Keys created since the matching
enter call except for the listed Keys.
|
static Key[] |
pop()
Pop-scope (same as exit-scope) but return all keys that are tracked (and
would have been deleted).
|
static <T extends Keyed> |
track_generic(Keyed<T> keyed) |
static Frame |
track(Frame... frames)
Track one or more
Frame s, and return the first one. |
static Vec |
track(Vec vec) |
static void |
untrack(java.lang.Iterable<Key<Vec>> keys) |
static void |
untrack(Key<Vec>... keys) |
public static void enter()
public static Key[] exit(Key... keep)
public static Key[] pop()
public static Frame track(Frame... frames)
Frame
s, and return the first one. The tracked
frames will be removed from DKV when exit(Key[])
is called.