[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / Sleeper.cs
1 using org.ldk.impl;
2 using org.ldk.enums;
3 using org.ldk.util;
4 using System;
5
6 namespace org { namespace ldk { namespace structs {
7
8
9 /**
10  * A struct which can be used to select across many [`Future`]s at once without relying on a full
11  * async context.
12  */
13 public class Sleeper : CommonBase {
14         internal Sleeper(object _dummy, long ptr) : base(ptr) { }
15         ~Sleeper() {
16                 if (ptr != 0) { bindings.Sleeper_free(ptr); }
17         }
18
19         /**
20          * Constructs a new sleeper from one future, allowing blocking on it.
21          */
22         public static Sleeper from_single_future(org.ldk.structs.Future future) {
23                 long ret = bindings.Sleeper_from_single_future(future == null ? 0 : future.ptr);
24                 GC.KeepAlive(future);
25                 if (ret >= 0 && ret <= 4096) { return null; }
26                 org.ldk.structs.Sleeper ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Sleeper(null, ret); }
27                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
28                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(future); };
29                 return ret_hu_conv;
30         }
31
32         /**
33          * Constructs a new sleeper from two futures, allowing blocking on both at once.
34          */
35         public static Sleeper from_two_futures(org.ldk.structs.Future fut_a, org.ldk.structs.Future fut_b) {
36                 long ret = bindings.Sleeper_from_two_futures(fut_a == null ? 0 : fut_a.ptr, fut_b == null ? 0 : fut_b.ptr);
37                 GC.KeepAlive(fut_a);
38                 GC.KeepAlive(fut_b);
39                 if (ret >= 0 && ret <= 4096) { return null; }
40                 org.ldk.structs.Sleeper ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Sleeper(null, ret); }
41                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
42                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(fut_a); };
43                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(fut_b); };
44                 return ret_hu_conv;
45         }
46
47         /**
48          * Constructs a new sleeper on many futures, allowing blocking on all at once.
49          */
50         public static Sleeper of(Future[] futures) {
51                 long ret = bindings.Sleeper_new(InternalUtils.encodeUint64Array(InternalUtils.mapArray(futures, futures_conv_8 => futures_conv_8 == null ? 0 : futures_conv_8.ptr)));
52                 GC.KeepAlive(futures);
53                 if (ret >= 0 && ret <= 4096) { return null; }
54                 org.ldk.structs.Sleeper ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Sleeper(null, ret); }
55                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
56                 foreach (Future futures_conv_8 in futures) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(futures_conv_8); }; };
57                 return ret_hu_conv;
58         }
59
60         /**
61          * Wait until one of the [`Future`]s registered with this [`Sleeper`] has completed.
62          */
63         public void wait() {
64                 bindings.Sleeper_wait(this.ptr);
65                 GC.KeepAlive(this);
66         }
67
68         /**
69          * Wait until one of the [`Future`]s registered with this [`Sleeper`] has completed or the
70          * given amount of time has elapsed. Returns true if a [`Future`] completed, false if the time
71          * elapsed.
72          */
73         public bool wait_timeout(long max_wait) {
74                 bool ret = bindings.Sleeper_wait_timeout(this.ptr, max_wait);
75                 GC.KeepAlive(this);
76                 GC.KeepAlive(max_wait);
77                 return ret;
78         }
79
80 }
81 } } }