Update auto-generated bindings to 0.0.103
[ldk-java] / src / main / java / org / ldk / structs / LockableScore.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7 import javax.annotation.Nullable;
8
9
10 /**
11  * A scorer that is accessed under a lock.
12  * 
13  * Needed so that calls to [`Score::channel_penalty_msat`] in [`find_route`] can be made while
14  * having shared ownership of a scorer but without requiring internal locking in [`Score`]
15  * implementations. Internal locking would be detrimental to route finding performance and could
16  * result in [`Score::channel_penalty_msat`] returning a different value for the same channel.
17  * 
18  * [`find_route`]: crate::routing::router::find_route
19  */
20 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
21 public class LockableScore extends CommonBase {
22         LockableScore(Object _dummy, long ptr) { super(ptr); }
23         @Override @SuppressWarnings("deprecation")
24         protected void finalize() throws Throwable {
25                 super.finalize();
26                 if (ptr != 0) { bindings.LockableScore_free(ptr); }
27         }
28
29         /**
30          * Constructs a new LockableScore from a Score
31          */
32         public static LockableScore of(Score score) {
33                 long ret = bindings.LockableScore_new(score == null ? 0 : score.ptr);
34                 if (ret >= 0 && ret <= 4096) { return null; }
35                 LockableScore ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new LockableScore(null, ret); }
36                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
37                 ret_hu_conv.ptrs_to.add(score);
38                 return ret_hu_conv;
39         }
40
41         /**
42          * Serialize the LockableScore object into a byte array which can be read by LockableScore_read
43          */
44         public byte[] write() {
45                 byte[] ret = bindings.LockableScore_write(this.ptr);
46                 return ret;
47         }
48
49 }