[Java] Update auto-generated Java bindings
[ldk-java] / src / main / java / org / ldk / structs / FutureCallback.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  * A callback which is called when a [`Future`] completes.
12  * 
13  * Note that this MUST NOT call back into LDK directly, it must instead schedule actions to be
14  * taken later. Rust users should use the [`std::future::Future`] implementation for [`Future`]
15  * instead.
16  * 
17  * Note that the [`std::future::Future`] implementation may only work for runtimes which schedule
18  * futures when they receive a wake, rather than immediately executing them.
19  */
20 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
21 public class FutureCallback extends CommonBase {
22         final bindings.LDKFutureCallback bindings_instance;
23         FutureCallback(Object _dummy, long ptr) { super(ptr); bindings_instance = null; }
24         private FutureCallback(bindings.LDKFutureCallback arg) {
25                 super(bindings.LDKFutureCallback_new(arg));
26                 this.ptrs_to.add(arg);
27                 this.bindings_instance = arg;
28         }
29         @Override @SuppressWarnings("deprecation")
30         protected void finalize() throws Throwable {
31                 if (ptr != 0) { bindings.FutureCallback_free(ptr); } super.finalize();
32         }
33         /**
34          * Destroys the object, freeing associated resources. After this call, any access
35          * to this object may result in a SEGFAULT or worse.
36          *
37          * You should generally NEVER call this method. You should let the garbage collector
38          * do this for you when it finalizes objects. However, it may be useful for types
39          * which represent locks and should be closed immediately to avoid holding locks
40          * until the GC runs.
41          */
42         public void destroy() {
43                 if (ptr != 0) { bindings.FutureCallback_free(ptr); }
44                 ptr = 0;
45         }
46         public static interface FutureCallbackInterface {
47                 /**
48                  * The method which is called.
49                  */
50                 void call();
51         }
52         private static class LDKFutureCallbackHolder { FutureCallback held; }
53         public static FutureCallback new_impl(FutureCallbackInterface arg) {
54                 final LDKFutureCallbackHolder impl_holder = new LDKFutureCallbackHolder();
55                 impl_holder.held = new FutureCallback(new bindings.LDKFutureCallback() {
56                         @Override public void call() {
57                                 arg.call();
58                                 Reference.reachabilityFence(arg);
59                         }
60                 });
61                 return impl_holder.held;
62         }
63         /**
64          * The method which is called.
65          */
66         public void call() {
67                 bindings.FutureCallback_call(this.ptr);
68                 Reference.reachabilityFence(this);
69         }
70
71 }