5fa004adb38c7a3715cb2ca7cfabda5b87bc5761
[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 == null ? 0 : callback.ptr);
24                 GC.KeepAlive(this);
25                 GC.KeepAlive(callback);
26                 if (this != null) { this.ptrs_to.AddLast(callback); };
27         }
28
29 }
30 } } }