[TS] Update auto-generated bindings to LDK-C-Bindings 0.0.123.1
[ldk-java] / c_sharp / src / org / ldk / structs / Future.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 simple future which can complete once, and calls some callback(s) when it does so.
11  */
12 public class Future : CommonBase {
13         internal Future(object _dummy, long ptr) : base(ptr) { }
14         ~Future() {
15                 if (ptr != 0) { bindings.Future_free(ptr); }
16         }
17
18         /**
19          * Registers a callback to be called upon completion of this future. If the future has already
20          * completed, the callback will be called immediately.
21          */
22         public void register_callback_fn(org.ldk.structs.FutureCallback callback) {
23                 bindings.Future_register_callback_fn(this.ptr, callback.ptr);
24                 GC.KeepAlive(this);
25                 GC.KeepAlive(callback);
26                 if (this != null) { this.ptrs_to.AddLast(callback); };
27         }
28
29         /**
30          * Waits until this [`Future`] completes.
31          */
32         public void wait() {
33                 bindings.Future_wait(this.ptr);
34                 GC.KeepAlive(this);
35         }
36
37         /**
38          * Waits until this [`Future`] completes or the given amount of time has elapsed.
39          * 
40          * Returns true if the [`Future`] completed, false if the time elapsed.
41          */
42         public bool wait_timeout(long max_wait) {
43                 bool ret = bindings.Future_wait_timeout(this.ptr, max_wait);
44                 GC.KeepAlive(this);
45                 GC.KeepAlive(max_wait);
46                 return ret;
47         }
48
49 }
50 } } }