+
using org.ldk.impl;
using org.ldk.enums;
using org.ldk.util;
namespace org { namespace ldk { namespace structs {
+
+
+/** An implementation of FutureCallback */
+public interface FutureCallbackInterface {
+ /**The method which is called.
+ */
+ void call();
+}
+
/**
* A callback which is called when a [`Future`] completes.
*
* futures when they receive a wake, rather than immediately executing them.
*/
public class FutureCallback : CommonBase {
- internal readonly bindings.LDKFutureCallback bindings_instance;
+ internal bindings.LDKFutureCallback bindings_instance;
+ internal long instance_idx;
+
internal FutureCallback(object _dummy, long ptr) : base(ptr) { bindings_instance = null; }
- private FutureCallback(bindings.LDKFutureCallback arg) : base(bindings.LDKFutureCallback_new(arg)) {
- this.ptrs_to.AddLast(arg);
- this.bindings_instance = arg;
- }
~FutureCallback() {
if (ptr != 0) { bindings.FutureCallback_free(ptr); }
}
- public interface FutureCallbackInterface {
- /**
- * The method which is called.
- */
- void call();
- }
private class LDKFutureCallbackHolder { internal FutureCallback held; }
private class LDKFutureCallbackImpl : bindings.LDKFutureCallback {
internal LDKFutureCallbackImpl(FutureCallbackInterface arg, LDKFutureCallbackHolder impl_holder) { this.arg = arg; this.impl_holder = impl_holder; }
GC.KeepAlive(arg);
}
}
+
+ /** Creates a new instance of FutureCallback from a given implementation */
public static FutureCallback new_impl(FutureCallbackInterface arg) {
LDKFutureCallbackHolder impl_holder = new LDKFutureCallbackHolder();
- impl_holder.held = new FutureCallback(new LDKFutureCallbackImpl(arg, impl_holder));
+ LDKFutureCallbackImpl impl = new LDKFutureCallbackImpl(arg, impl_holder);
+ long[] ptr_idx = bindings.LDKFutureCallback_new(impl);
+
+ impl_holder.held = new FutureCallback(null, ptr_idx[0]);
+ impl_holder.held.instance_idx = ptr_idx[1];
+ impl_holder.held.bindings_instance = impl;
return impl_holder.held;
}
+
/**
* The method which is called.
*/