6 namespace org { namespace ldk { namespace structs {
10 * A struct which can be used to select across many [`Future`]s at once without relying on a full
13 public class Sleeper : CommonBase {
14 internal Sleeper(object _dummy, long ptr) : base(ptr) { }
16 if (ptr != 0) { bindings.Sleeper_free(ptr); }
20 * Constructs a new sleeper from one future, allowing blocking on it.
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);
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); };
33 * Constructs a new sleeper from two futures, allowing blocking on both at once.
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);
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); };
48 * Constructs a new sleeper on many futures, allowing blocking on all at once.
50 public static Sleeper of(Future[] futures) {
51 long ret = bindings.Sleeper_new(futures != null ? InternalUtils.mapArray(futures, futures_conv_8 => futures_conv_8 == null ? 0 : futures_conv_8.ptr) : null);
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); }; };
61 * Wait until one of the [`Future`]s registered with this [`Sleeper`] has completed.
64 bindings.Sleeper_wait(this.ptr);
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
73 public bool wait_timeout(long max_wait) {
74 bool ret = bindings.Sleeper_wait_timeout(this.ptr, max_wait);
76 GC.KeepAlive(max_wait);