]> git.bitcoin.ninja Git - ldk-java/blob - src/main/java/org/ldk/structs/EventsProvider.java
Fix race in tests
[ldk-java] / src / main / java / org / ldk / structs / EventsProvider.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
8 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
9 public class EventsProvider extends CommonBase {
10         final bindings.LDKEventsProvider bindings_instance;
11         EventsProvider(Object _dummy, long ptr) { super(ptr); bindings_instance = null; }
12         private EventsProvider(bindings.LDKEventsProvider arg) {
13                 super(bindings.LDKEventsProvider_new(arg));
14                 this.ptrs_to.add(arg);
15                 this.bindings_instance = arg;
16         }
17         @Override @SuppressWarnings("deprecation")
18         protected void finalize() throws Throwable {
19                 if (ptr != 0) { bindings.EventsProvider_free(ptr); } super.finalize();
20         }
21
22         public static interface EventsProviderInterface {
23                 Event[] get_and_clear_pending_events();
24         }
25         private static class LDKEventsProviderHolder { EventsProvider held; }
26         public static EventsProvider new_impl(EventsProviderInterface arg) {
27                 final LDKEventsProviderHolder impl_holder = new LDKEventsProviderHolder();
28                 impl_holder.held = new EventsProvider(new bindings.LDKEventsProvider() {
29                         @Override public long[] get_and_clear_pending_events() {
30                                 Event[] ret = arg.get_and_clear_pending_events();
31                                 long[] result = Arrays.stream(ret).mapToLong(arr_conv_7 -> arr_conv_7.ptr).toArray();
32                                 /* TODO 2 Event  */;
33                                 return result;
34                         }
35                 });
36                 return impl_holder.held;
37         }
38         public Event[] get_and_clear_pending_events() {
39                 long[] ret = bindings.EventsProvider_get_and_clear_pending_events(this.ptr);
40                 Event[] arr_conv_7_arr = new Event[ret.length];
41                 for (int h = 0; h < ret.length; h++) {
42                         long arr_conv_7 = ret[h];
43                         Event arr_conv_7_hu_conv = Event.constr_from_ptr(arr_conv_7);
44                         arr_conv_7_hu_conv.ptrs_to.add(this);
45                         arr_conv_7_arr[h] = arr_conv_7_hu_conv;
46                 }
47                 return arr_conv_7_arr;
48         }
49
50 }