[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / LockableScore.cs
1
2 using org.ldk.impl;
3 using org.ldk.enums;
4 using org.ldk.util;
5 using System;
6
7 namespace org { namespace ldk { namespace structs {
8
9
10
11 /** An implementation of LockableScore */
12 public interface LockableScoreInterface {
13         /**Returns read locked scorer.
14          */
15         ScoreLookUp read_lock();
16         /**Returns write locked scorer.
17          */
18         ScoreUpdate write_lock();
19 }
20
21 /**
22  * A scorer that is accessed under a lock.
23  * 
24  * Needed so that calls to [`ScoreLookUp::channel_penalty_msat`] in [`find_route`] can be made while
25  * having shared ownership of a scorer but without requiring internal locking in [`ScoreUpdate`]
26  * implementations. Internal locking would be detrimental to route finding performance and could
27  * result in [`ScoreLookUp::channel_penalty_msat`] returning a different value for the same channel.
28  * 
29  * [`find_route`]: crate::routing::router::find_route
30  */
31 public class LockableScore : CommonBase {
32         internal bindings.LDKLockableScore bindings_instance;
33         internal long instance_idx;
34
35         internal LockableScore(object _dummy, long ptr) : base(ptr) { bindings_instance = null; }
36         ~LockableScore() {
37                 if (ptr != 0) { bindings.LockableScore_free(ptr); }
38         }
39
40         private class LDKLockableScoreHolder { internal LockableScore held; }
41         private class LDKLockableScoreImpl : bindings.LDKLockableScore {
42                 internal LDKLockableScoreImpl(LockableScoreInterface arg, LDKLockableScoreHolder impl_holder) { this.arg = arg; this.impl_holder = impl_holder; }
43                 private LockableScoreInterface arg;
44                 private LDKLockableScoreHolder impl_holder;
45                 public long read_lock() {
46                         ScoreLookUp ret = arg.read_lock();
47                                 GC.KeepAlive(arg);
48                         long result = ret.ptr;
49                         if (impl_holder.held != null) { impl_holder.held.ptrs_to.AddLast(ret); };
50                         return result;
51                 }
52                 public long write_lock() {
53                         ScoreUpdate ret = arg.write_lock();
54                                 GC.KeepAlive(arg);
55                         long result = ret.ptr;
56                         if (impl_holder.held != null) { impl_holder.held.ptrs_to.AddLast(ret); };
57                         return result;
58                 }
59         }
60
61         /** Creates a new instance of LockableScore from a given implementation */
62         public static LockableScore new_impl(LockableScoreInterface arg) {
63                 LDKLockableScoreHolder impl_holder = new LDKLockableScoreHolder();
64                 LDKLockableScoreImpl impl = new LDKLockableScoreImpl(arg, impl_holder);
65                 long[] ptr_idx = bindings.LDKLockableScore_new(impl);
66
67                 impl_holder.held = new LockableScore(null, ptr_idx[0]);
68                 impl_holder.held.instance_idx = ptr_idx[1];
69                 impl_holder.held.bindings_instance = impl;
70                 return impl_holder.held;
71         }
72
73         /**
74          * Returns read locked scorer.
75          */
76         public ScoreLookUp read_lock() {
77                 long ret = bindings.LockableScore_read_lock(this.ptr);
78                 GC.KeepAlive(this);
79                 if (ret >= 0 && ret <= 4096) { return null; }
80                 ScoreLookUp ret_hu_conv = new ScoreLookUp(null, ret);
81                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
82                 return ret_hu_conv;
83         }
84
85         /**
86          * Returns write locked scorer.
87          */
88         public ScoreUpdate write_lock() {
89                 long ret = bindings.LockableScore_write_lock(this.ptr);
90                 GC.KeepAlive(this);
91                 if (ret >= 0 && ret <= 4096) { return null; }
92                 ScoreUpdate ret_hu_conv = new ScoreUpdate(null, ret);
93                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
94                 return ret_hu_conv;
95         }
96
97 }
98 } } }