6 namespace org { namespace ldk { namespace structs {
9 * A callback which is called when a [`Future`] completes.
11 * Note that this MUST NOT call back into LDK directly, it must instead schedule actions to be
12 * taken later. Rust users should use the [`std::future::Future`] implementation for [`Future`]
15 * Note that the [`std::future::Future`] implementation may only work for runtimes which schedule
16 * futures when they receive a wake, rather than immediately executing them.
18 public class FutureCallback : CommonBase {
19 internal readonly bindings.LDKFutureCallback bindings_instance;
20 internal FutureCallback(object _dummy, long ptr) : base(ptr) { bindings_instance = null; }
21 private FutureCallback(bindings.LDKFutureCallback arg) : base(bindings.LDKFutureCallback_new(arg)) {
22 this.ptrs_to.AddLast(arg);
23 this.bindings_instance = arg;
26 if (ptr != 0) { bindings.FutureCallback_free(ptr); }
29 public interface FutureCallbackInterface {
31 * The method which is called.
35 private class LDKFutureCallbackHolder { internal FutureCallback held; }
36 private class LDKFutureCallbackImpl : bindings.LDKFutureCallback {
37 internal LDKFutureCallbackImpl(FutureCallbackInterface arg, LDKFutureCallbackHolder impl_holder) { this.arg = arg; this.impl_holder = impl_holder; }
38 private FutureCallbackInterface arg;
39 private LDKFutureCallbackHolder impl_holder;
45 public static FutureCallback new_impl(FutureCallbackInterface arg) {
46 LDKFutureCallbackHolder impl_holder = new LDKFutureCallbackHolder();
47 impl_holder.held = new FutureCallback(new LDKFutureCallbackImpl(arg, impl_holder));
48 return impl_holder.held;
51 * The method which is called.
54 bindings.FutureCallback_call(this.ptr);