]> git.bitcoin.ninja Git - ldk-java/blob - src/main/java/org/ldk/structs/SocketDescriptor.java
Fix race in tests
[ldk-java] / src / main / java / org / ldk / structs / SocketDescriptor.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 SocketDescriptor extends CommonBase {
10         final bindings.LDKSocketDescriptor bindings_instance;
11         SocketDescriptor(Object _dummy, long ptr) { super(ptr); bindings_instance = null; }
12         private SocketDescriptor(bindings.LDKSocketDescriptor arg) {
13                 super(bindings.LDKSocketDescriptor_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.SocketDescriptor_free(ptr); } super.finalize();
20         }
21
22         public static interface SocketDescriptorInterface {
23                 long send_data(byte[] data, boolean resume_read);
24                 void disconnect_socket();
25                 boolean eq(SocketDescriptor other_arg);
26                 long hash();
27         }
28         private static class LDKSocketDescriptorHolder { SocketDescriptor held; }
29         public static SocketDescriptor new_impl(SocketDescriptorInterface arg) {
30                 final LDKSocketDescriptorHolder impl_holder = new LDKSocketDescriptorHolder();
31                 impl_holder.held = new SocketDescriptor(new bindings.LDKSocketDescriptor() {
32                         @Override public long send_data(byte[] data, boolean resume_read) {
33                                 long ret = arg.send_data(data, resume_read);
34                                 return ret;
35                         }
36                         @Override public void disconnect_socket() {
37                                 arg.disconnect_socket();
38                         }
39                         @Override public boolean eq(long other_arg) {
40                                 SocketDescriptor ret_hu_conv = new SocketDescriptor(null, other_arg);
41                                 ret_hu_conv.ptrs_to.add(this);
42                                 boolean ret = arg.eq(ret_hu_conv);
43                                 return ret;
44                         }
45                         @Override public long hash() {
46                                 long ret = arg.hash();
47                                 return ret;
48                         }
49                 });
50                 return impl_holder.held;
51         }
52         public long send_data(byte[] data, boolean resume_read) {
53                 long ret = bindings.SocketDescriptor_send_data(this.ptr, data, resume_read);
54                 return ret;
55         }
56
57         public void disconnect_socket() {
58                 bindings.SocketDescriptor_disconnect_socket(this.ptr);
59         }
60
61         public long hash() {
62                 long ret = bindings.SocketDescriptor_hash(this.ptr);
63                 return ret;
64         }
65
66         public static SocketDescriptor constructor_clone(SocketDescriptor orig) {
67                 long ret = bindings.SocketDescriptor_clone(orig == null ? 0 : orig.ptr);
68                 SocketDescriptor ret_hu_conv = new SocketDescriptor(null, ret);
69                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
70                 ret_hu_conv.ptrs_to.add(orig);
71                 return ret_hu_conv;
72         }
73
74 }