1 // Generated by jextract
2
3 package oracle.code.onnx.foreign;
4
5 import java.lang.invoke.*;
6 import java.lang.foreign.*;
7 import java.nio.ByteOrder;
8 import java.util.*;
9 import java.util.function.*;
10 import java.util.stream.*;
11
12 import static java.lang.foreign.ValueLayout.*;
13 import static java.lang.foreign.MemoryLayout.PathElement.*;
14
15 /**
16 * {@snippet lang=c :
17 * typedef void (*OrtThreadPoolWorkStopFn)(void *, void *)
18 * }
19 */
20 public final class OrtThreadPoolWorkStopFn {
21
22 private OrtThreadPoolWorkStopFn() {
23 // Should not be called directly
24 }
25
26 /**
27 * The function pointer signature, expressed as a functional interface
28 */
29 public interface Function {
30 void apply(MemorySegment user_context, MemorySegment enqueue_data);
31 }
32
33 private static final FunctionDescriptor $DESC = FunctionDescriptor.ofVoid(
34 onnxruntime_c_api_h.C_POINTER,
35 onnxruntime_c_api_h.C_POINTER
36 );
37
38 /**
39 * The descriptor of this function pointer
40 */
41 public static FunctionDescriptor descriptor() {
42 return $DESC;
43 }
44
45 private static final MethodHandle UP$MH = onnxruntime_c_api_h.upcallHandle(OrtThreadPoolWorkStopFn.Function.class, "apply", $DESC);
46
47 /**
48 * Allocates a new upcall stub, whose implementation is defined by {@code fi}.
49 * The lifetime of the returned segment is managed by {@code arena}
50 */
51 public static MemorySegment allocate(OrtThreadPoolWorkStopFn.Function fi, Arena arena) {
52 return Linker.nativeLinker().upcallStub(UP$MH.bindTo(fi), $DESC, arena);
53 }
54
55 private static final MethodHandle DOWN$MH = Linker.nativeLinker().downcallHandle($DESC);
56
57 /**
58 * Invoke the upcall stub {@code funcPtr}, with given parameters
59 */
60 public static void invoke(MemorySegment funcPtr, MemorySegment user_context, MemorySegment enqueue_data) {
61 try {
62 DOWN$MH.invokeExact(funcPtr, user_context, enqueue_data);
63 } catch (Error | RuntimeException ex) {
64 throw ex;
65 } catch (Throwable ex$) {
66 throw new AssertionError("should not reach here", ex$);
67 }
68 }
69 }
70