6 namespace org { namespace ldk { namespace structs {
10 * A simple future which can complete once, and calls some callback(s) when it does so.
12 * Clones can be made and all futures cloned from the same source will complete at the same time.
14 public class Future : CommonBase {
15 internal Future(object _dummy, long ptr) : base(ptr) { }
17 if (ptr != 0) { bindings.Future_free(ptr); }
20 internal long clone_ptr() {
21 long ret = bindings.Future_clone_ptr(this.ptr);
27 * Creates a copy of the Future
29 public Future clone() {
30 long ret = bindings.Future_clone(this.ptr);
32 if (ret >= 0 && ret <= 4096) { return null; }
33 org.ldk.structs.Future ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Future(null, ret); }
34 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
39 * Registers a callback to be called upon completion of this future. If the future has already
40 * completed, the callback will be called immediately.
42 public void register_callback_fn(org.ldk.structs.FutureCallback callback) {
43 bindings.Future_register_callback_fn(this.ptr, callback.ptr);
45 GC.KeepAlive(callback);
46 if (this != null) { this.ptrs_to.AddLast(callback); };
50 * Waits until this [`Future`] completes.
53 bindings.Future_wait(this.ptr);
55 if (this != null) { this.ptrs_to.AddLast(this); };
59 * Waits until this [`Future`] completes or the given amount of time has elapsed.
61 * Returns true if the [`Future`] completed, false if the time elapsed.
63 public bool wait_timeout(long max_wait) {
64 bool ret = bindings.Future_wait_timeout(this.ptr, max_wait);
66 GC.KeepAlive(max_wait);
67 if (this != null) { this.ptrs_to.AddLast(this); };