[Java] Update auto-generated bindings to 0.0.115
[ldk-java] / src / main / java / org / ldk / structs / Future.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
9
10
11 /**
12  * A simple future which can complete once, and calls some callback(s) when it does so.
13  * 
14  * Clones can be made and all futures cloned from the same source will complete at the same time.
15  */
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class Future extends CommonBase {
18         Future(Object _dummy, long ptr) { super(ptr); }
19         @Override @SuppressWarnings("deprecation")
20         protected void finalize() throws Throwable {
21                 super.finalize();
22                 if (ptr != 0) { bindings.Future_free(ptr); }
23         }
24
25         long clone_ptr() {
26                 long ret = bindings.Future_clone_ptr(this.ptr);
27                 Reference.reachabilityFence(this);
28                 return ret;
29         }
30
31         /**
32          * Creates a copy of the Future
33          */
34         public Future clone() {
35                 long ret = bindings.Future_clone(this.ptr);
36                 Reference.reachabilityFence(this);
37                 if (ret >= 0 && ret <= 4096) { return null; }
38                 org.ldk.structs.Future ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Future(null, ret); }
39                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
40                 return ret_hu_conv;
41         }
42
43         /**
44          * Registers a callback to be called upon completion of this future. If the future has already
45          * completed, the callback will be called immediately.
46          */
47         public void register_callback_fn(org.ldk.structs.FutureCallback callback) {
48                 bindings.Future_register_callback_fn(this.ptr, callback == null ? 0 : callback.ptr);
49                 Reference.reachabilityFence(this);
50                 Reference.reachabilityFence(callback);
51                 if (this != null) { this.ptrs_to.add(callback); };
52         }
53
54         /**
55          * Waits until this [`Future`] completes.
56          */
57         public void wait_indefinite() {
58                 bindings.Future_wait(this.ptr);
59                 Reference.reachabilityFence(this);
60                 if (this != null) { this.ptrs_to.add(this); };
61         }
62
63         /**
64          * Waits until this [`Future`] completes or the given amount of time has elapsed.
65          * 
66          * Returns true if the [`Future`] completed, false if the time elapsed.
67          */
68         public boolean wait_timeout(long max_wait) {
69                 boolean ret = bindings.Future_wait_timeout(this.ptr, max_wait);
70                 Reference.reachabilityFence(this);
71                 Reference.reachabilityFence(max_wait);
72                 if (this != null) { this.ptrs_to.add(this); };
73                 return ret;
74         }
75
76 }