LivenessScope
LivenessScope
is a Groovy class that manages the reference counting of tables and other query resources that are created within it.
Syntax
scope = new LivenessScope()
Parameters
None.
Returns
An instance of a LivenessScope
class.
Examples
The following example uses function-generated tables to produce a blink table with 5 new rows per second. Encapsulating the function-generated table inside a liveness scope enables the safe deletion of data once the scope has been released. tableFromFunc
will continue to tick after the scope is released until all referents have been deleted, including the ticking table in the UI.
import io.deephaven.engine.liveness.*
import io.deephaven.util.SafeCloseable
import io.deephaven.engine.table.impl.util.FunctionGeneratedTableFactory
randomData = { ->
return emptyTable(5).update("X = randomInt(0, 10)", "Y = randomDouble(-50.0, 50.0)")
}
scope = new LivenessScope()
try ( SafeCloseable ignored = LivenessScopeStack.open(scope, false) ) {
tableFromFunc = FunctionGeneratedTableFactory.create(randomData, 1000)
}
// After a while...
tableFromFunc = null
scope.release()