public final class XPRBexprContext
extends java.lang.Object
implements java.lang.AutoCloseable
XPRBexpr
instances.
This class is intended to be use in a way similar to this:
try (XPRBprob prob = bcl.newProb("")) {
try (XPRBexprContext context = new XPRBexprContext()) {
...
// Code that creates XPRBexpr instances without explicitly close()ing them
...
} // all XPRBexpr instances automatically closed here
}
Once an instance of XPRBexprContext is created, it tracks all
XPRBexpr instances that are created on the same thread.
If the XPRBexprContext instance is then eventually closed
(by explicitly or implicitly calling close()), all the tracked
XPRBexpr instances will be closed as well.
There can be only one XPRBexprContext instance per thread.
Creating a second one without first closing the first one will raise an
exception.
Function close() must be called on the same thread that
created the XPRBexprContext instance.
| Constructor and Description |
|---|
XPRBexprContext()
Create a new
XPRBexprContext. |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Release all tracked
XPRBexpr instances and stop tracking on
the current thread. |
public XPRBexprContext()
XPRBexprContext.
Once such a context is created, it will track all XPRBexpr
instances created on the same thread that created the
XPRBexprContext.
When close() is called on that instance then all tracked
XPRBexpr instances will be closed as well.
There can be only one XPRBexprContext instance per thread.
Creating a second one before first closing the first one will raise an
exception.java.lang.IllegalStateException - if there already is an
XPRBexprContext for this
thread.public void close()
XPRBexpr instances and stop tracking on
the current thread.
This function must be invoked from the same thread that created this
instance.close in interface java.lang.AutoCloseable