- public Event[] get_and_clear_pending_events() {
- long[] ret = bindings.EventsProvider_get_and_clear_pending_events(this.ptr);
- Event[] arr_conv_7_arr = new Event[ret.length];
- for (int h = 0; h < ret.length; h++) {
- long arr_conv_7 = ret[h];
- Event arr_conv_7_hu_conv = Event.constr_from_ptr(arr_conv_7);
- arr_conv_7_arr[h] = arr_conv_7_hu_conv;
- }
- return arr_conv_7_arr;
+ public static interface EventsProviderInterface {
+ /**
+ * Processes any events generated since the last call using the given event handler.
+ *
+ * Subsequent calls must only process new events. However, handlers must be capable of handling
+ * duplicate events across process restarts. This may occur if the provider was recovered from
+ * an old state (i.e., it hadn't been successfully persisted after processing pending events).
+ */
+ void process_pending_events(EventHandler handler);
+ }
+ private static class LDKEventsProviderHolder { EventsProvider held; }
+ public static EventsProvider new_impl(EventsProviderInterface arg) {
+ final LDKEventsProviderHolder impl_holder = new LDKEventsProviderHolder();
+ impl_holder.held = new EventsProvider(new bindings.LDKEventsProvider() {
+ @Override public void process_pending_events(long handler) {
+ EventHandler ret_hu_conv = new EventHandler(null, handler);
+ ret_hu_conv.ptrs_to.add(this);
+ arg.process_pending_events(ret_hu_conv);
+ }
+ });
+ return impl_holder.held;
+ }
+ /**
+ * Processes any events generated since the last call using the given event handler.
+ *
+ * Subsequent calls must only process new events. However, handlers must be capable of handling
+ * duplicate events across process restarts. This may occur if the provider was recovered from
+ * an old state (i.e., it hadn't been successfully persisted after processing pending events).
+ */
+ public void process_pending_events(EventHandler handler) {
+ bindings.EventsProvider_process_pending_events(this.ptr, handler == null ? 0 : handler.ptr);
+ Reference.reachabilityFence(this);
+ Reference.reachabilityFence(handler);
+ this.ptrs_to.add(handler);