+ /**
+ * Exposes the `ProbabilisticScorer` wrapped inside a lock. Don't forget to `close` this lock when you're done with
+ * it so normal scoring operation can continue.
+ */
+ public class ScorerWrapper implements AutoCloseable {
+ private final Score lock;
+ public final ProbabilisticScorer prob_scorer;
+ private ScorerWrapper(Score lock, ProbabilisticScorer prob_scorer) {
+ this.lock = lock; this.prob_scorer = prob_scorer;
+ }
+ @Override public void close() throws Exception {
+ lock.destroy();
+ }
+ }
+ /**
+ * Gets the `ProbabilisticScorer` which backs the public lockable `scorer`. Don't forget to `close` the lock when
+ * you're done with it.
+ */
+ public ScorerWrapper get_locked_scorer() {
+ return new ScorerWrapper(this.scorer.as_LockableScore().lock(), this.prob_scorer);
+ }
+