XPRBexprContext
- java.lang.Object
-
- com.dashoptimization.XPRBexprContext
-
- All Implemented Interfaces:
- java.lang.AutoCloseable
public final class XPRBexprContext extends java.lang.Object implements java.lang.AutoCloseable
Simplified handling of native resources associated withXPRBexpr
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 allXPRBexpr
instances that are created on the same thread.If the
XPRBexprContext
instance is then eventually closed (by explicitly or implicitly callingclose()
), all the trackedXPRBexpr
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 theXPRBexprContext
instance.
-
-
Constructor Summary
Constructor and Description XPRBexprContext()
Create a newXPRBexprContext
.
-
-
-
Constructor Detail
-
XPRBexprContext
public XPRBexprContext()
Create a newXPRBexprContext
. Once such a context is created, it will track allXPRBexpr
instances created on the same thread that created theXPRBexprContext
. Whenclose()
is called on that instance then all trackedXPRBexpr
instances will be closed as well. There can be only oneXPRBexprContext
instance per thread. Creating a second one before first closing the first one will raise an exception.- Throws:
-
java.lang.IllegalStateException
- if there already is anXPRBexprContext
for this thread.
-
-
Method Detail
-
close
public void close()
Release all trackedXPRBexpr
instances and stop tracking on the current thread. This function must be invoked from the same thread that created this instance.- Specified by:
-
close
in interfacejava.lang.AutoCloseable
-
-
© 2001-2024 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.