/**
* A scorer that is accessed under a lock.
*
- * Needed so that calls to [`Score::channel_penalty_msat`] in [`find_route`] can be made while
- * having shared ownership of a scorer but without requiring internal locking in [`Score`]
+ * Needed so that calls to [`ScoreLookUp::channel_penalty_msat`] in [`find_route`] can be made while
+ * having shared ownership of a scorer but without requiring internal locking in [`ScoreUpdate`]
* implementations. Internal locking would be detrimental to route finding performance and could
- * result in [`Score::channel_penalty_msat`] returning a different value for the same channel.
+ * result in [`ScoreLookUp::channel_penalty_msat`] returning a different value for the same channel.
*
* [`find_route`]: crate::routing::router::find_route
*/
}
public static interface LockableScoreInterface {
/**
- * Returns the locked scorer.
+ * Returns read locked scorer.
*/
- Score lock();
+ ScoreLookUp read_lock();
+ /**
+ * Returns write locked scorer.
+ */
+ ScoreUpdate write_lock();
}
private static class LDKLockableScoreHolder { LockableScore held; }
public static LockableScore new_impl(LockableScoreInterface arg) {
final LDKLockableScoreHolder impl_holder = new LDKLockableScoreHolder();
impl_holder.held = new LockableScore(new bindings.LDKLockableScore() {
- @Override public long lock() {
- Score ret = arg.lock();
+ @Override public long read_lock() {
+ ScoreLookUp ret = arg.read_lock();
+ Reference.reachabilityFence(arg);
+ long result = ret.ptr;
+ if (impl_holder.held != null) { impl_holder.held.ptrs_to.add(ret); };
+ return result;
+ }
+ @Override public long write_lock() {
+ ScoreUpdate ret = arg.write_lock();
Reference.reachabilityFence(arg);
long result = ret.ptr;
if (impl_holder.held != null) { impl_holder.held.ptrs_to.add(ret); };
return impl_holder.held;
}
/**
- * Returns the locked scorer.
+ * Returns read locked scorer.
+ */
+ public ScoreLookUp read_lock() {
+ long ret = bindings.LockableScore_read_lock(this.ptr);
+ Reference.reachabilityFence(this);
+ if (ret >= 0 && ret <= 4096) { return null; }
+ ScoreLookUp ret_hu_conv = new ScoreLookUp(null, ret);
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
+ return ret_hu_conv;
+ }
+
+ /**
+ * Returns write locked scorer.
*/
- public Score lock() {
- long ret = bindings.LockableScore_lock(this.ptr);
+ public ScoreUpdate write_lock() {
+ long ret = bindings.LockableScore_write_lock(this.ptr);
Reference.reachabilityFence(this);
if (ret >= 0 && ret <= 4096) { return null; }
- Score ret_hu_conv = new Score(null, ret);
+ ScoreUpdate ret_hu_conv = new ScoreUpdate(null, ret);
if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
return ret_hu_conv;
}