1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
12 * A simple future which can complete once, and calls some callback(s) when it does so.
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class Future extends CommonBase {
16 Future(Object _dummy, long ptr) { super(ptr); }
17 @Override @SuppressWarnings("deprecation")
18 protected void finalize() throws Throwable {
20 if (ptr != 0) { bindings.Future_free(ptr); }
24 * Registers a callback to be called upon completion of this future. If the future has already
25 * completed, the callback will be called immediately.
27 public void register_callback_fn(FutureCallback callback) {
28 bindings.Future_register_callback_fn(this.ptr, callback == null ? 0 : callback.ptr);
29 Reference.reachabilityFence(this);
30 Reference.reachabilityFence(callback);
31 if (this != null) { this.ptrs_to.add(callback); };