Simplify JNI init code (#10571)

Motivation:

Using classes which are not provided by the JDK itself in JNI is
problematic when shading may be used by customers of the library. Also
it makes the maintainance of the code often more complicated.

Modifications:

- Only us classes which are provided by the JDK in the JNI code
- Cleanup

Result:

Easier to maintain code
This commit is contained in:
Norman Maurer 2020-09-15 10:41:06 +02:00 committed by GitHub
parent d991105276
commit 0ef8fa47e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 142 additions and 150 deletions

View File

@ -59,12 +59,7 @@
#include <sys/eventfd.h> #include <sys/eventfd.h>
#include <poll.h> #include <poll.h>
static jmethodID ringBufferMethodId = NULL; static jclass longArrayClass = NULL;
static jmethodID ioUringSubmissionQueueMethodId = NULL;
static jmethodID ioUringCommpletionQueueMethodId = NULL;
static jclass ringBufferClass = NULL;
static jclass ioUringCompletionQueueClass = NULL;
static jclass ioUringSubmissionQueueClass = NULL;
static void netty_io_uring_native_JNI_OnUnLoad(JNIEnv* env) { static void netty_io_uring_native_JNI_OnUnLoad(JNIEnv* env) {
netty_unix_limits_JNI_OnUnLoad(env); netty_unix_limits_JNI_OnUnLoad(env);
@ -73,12 +68,7 @@ static void netty_io_uring_native_JNI_OnUnLoad(JNIEnv* env) {
netty_unix_socket_JNI_OnUnLoad(env); netty_unix_socket_JNI_OnUnLoad(env);
netty_unix_buffer_JNI_OnUnLoad(env); netty_unix_buffer_JNI_OnUnLoad(env);
ringBufferMethodId = NULL; longArrayClass = NULL;
ioUringSubmissionQueueMethodId = NULL;
ioUringCommpletionQueueMethodId = NULL;
ringBufferClass = NULL;
ioUringCompletionQueueClass = NULL;
ioUringSubmissionQueueClass = NULL;
} }
void io_uring_unmap_rings(struct io_uring_sq *sq, struct io_uring_cq *cq) { void io_uring_unmap_rings(struct io_uring_sq *sq, struct io_uring_cq *cq) {
@ -204,48 +194,39 @@ static void netty_io_uring_eventFdWrite(JNIEnv* env, jclass clazz, jint fd, jlon
} }
} }
static void netty_io_uring_ring_buffer_exit(JNIEnv *env, jclass class, jobject ringBuffer) { static void netty_io_uring_ring_buffer_exit(JNIEnv *env, jclass clazz,
// Find the id of the Java method to be called jlong submissionQueueArrayAddress, jint submissionQueueRingEntries, jlong submissionQueueRingAddress, jint submissionQueueRingSize,
jlong completionQueueRingAddress, jint completionQueueRingSize, jint ringFd) {
jclass ringBufferClass = (*env)->GetObjectClass(env, ringBuffer); munmap((struct io_uring_sqe*) submissionQueueArrayAddress, submissionQueueRingEntries * sizeof(struct io_uring_sqe));
jmethodID submissionQueueMethodId = (*env)->GetMethodID(env, ringBufferClass, "getIoUringSubmissionQueue", "()Lio/netty/channel/uring/IOUringSubmissionQueue;");
jmethodID completionQueueMethodId = (*env)->GetMethodID(env, ringBufferClass, "getIoUringCompletionQueue", "()Lio/netty/channel/uring/IOUringCompletionQueue;");
jobject submissionQueue = (*env)->CallObjectMethod(env, ringBuffer, submissionQueueMethodId);
jobject completionQueue = (*env)->CallObjectMethod(env, ringBuffer, completionQueueMethodId);
jclass submissionQueueClass = (*env)->GetObjectClass(env, submissionQueue);
jclass completionQueueClass = (*env)->GetObjectClass(env, completionQueue);
jfieldID submissionQueueArrayAddressFieldId = (*env)->GetFieldID(env, submissionQueueClass, "submissionQueueArrayAddress", "J");
jfieldID submissionQueueRingEntriesFieldId = (*env)->GetFieldID(env, submissionQueueClass, "ringEntries", "I");
jfieldID submissionQueueRingFdFieldId = (*env)->GetFieldID(env, submissionQueueClass, "ringFd", "I");
jfieldID submissionQueueRingAddressFieldId = (*env)->GetFieldID(env, submissionQueueClass, "ringAddress", "J");
jfieldID submissionQueueRingSizeFieldId = (*env)->GetFieldID(env, submissionQueueClass, "ringSize", "I");
jfieldID completionQueueRingAddressFieldId = (*env)->GetFieldID(env, completionQueueClass, "ringAddress", "J");
jfieldID completionQueueRingSizeFieldId = (*env)->GetFieldID(env, completionQueueClass, "ringSize", "I");
jlong submissionQueueArrayAddress = (*env)->GetLongField(env, submissionQueue, submissionQueueArrayAddressFieldId);
jint submissionQueueKringEntries = (*env)->GetIntField(env, submissionQueue, submissionQueueRingEntriesFieldId);
jint submissionQueueRingFd = (*env)->GetIntField(env, submissionQueue, submissionQueueRingFdFieldId);
jlong submissionQueueRingAddress = (*env)->GetLongField(env, submissionQueue, submissionQueueRingAddressFieldId);
jint submissionQueueRingSize = (*env)->GetIntField(env, submissionQueue, submissionQueueRingSizeFieldId);
jlong completionQueueRingAddress = (*env)->GetLongField(env, completionQueue, completionQueueRingAddressFieldId);
jint completionQueueRingSize = (*env)->GetIntField(env, completionQueue, completionQueueRingSizeFieldId);
munmap((struct io_uring_sqe*) submissionQueueArrayAddress, submissionQueueKringEntries * sizeof(struct io_uring_sqe));
munmap((void*) submissionQueueRingAddress, submissionQueueRingSize); munmap((void*) submissionQueueRingAddress, submissionQueueRingSize);
if (((void *) completionQueueRingAddress) && ((void *) completionQueueRingAddress) != ((void *) submissionQueueRingAddress)) { if (((void *) completionQueueRingAddress) && ((void *) completionQueueRingAddress) != ((void *) submissionQueueRingAddress)) {
munmap((void *)completionQueueRingAddress, completionQueueRingSize); munmap((void *)completionQueueRingAddress, completionQueueRingSize);
} }
close(submissionQueueRingFd); close(ringFd);
} }
static jobject netty_io_uring_setup(JNIEnv *env, jclass class1, jint entries, jobject submitCallback) { static jobjectArray netty_io_uring_setup(JNIEnv *env, jclass clazz, jint entries) {
struct io_uring_params p; struct io_uring_params p;
memset(&p, 0, sizeof(p)); memset(&p, 0, sizeof(p));
jobjectArray array = (*env)->NewObjectArray(env, 2, longArrayClass, NULL);
if (array == NULL) {
// This will put an OOME on the stack
return NULL;
}
jlongArray submissionArray = (*env)->NewLongArray(env, 11);
if (submissionArray == NULL) {
// This will put an OOME on the stack
return NULL;
}
jlongArray completionArray = (*env)->NewLongArray(env, 9);
if (completionArray == NULL) {
// This will put an OOME on the stack
return NULL;
}
int ring_fd = sys_io_uring_setup((int)entries, &p); int ring_fd = sys_io_uring_setup((int)entries, &p);
if (ring_fd < 0) { if (ring_fd < 0) {
@ -260,29 +241,37 @@ static jobject netty_io_uring_setup(JNIEnv *env, jclass class1, jint entries, jo
return NULL; return NULL;
} }
jobject ioUringSubmissionQueue = (*env)->NewObject( jlong submissionArrayElements[] = {
env, ioUringSubmissionQueueClass, ioUringSubmissionQueueMethodId, (jlong)io_uring_ring.sq.khead,
(jlong)io_uring_ring.sq.khead, (jlong)io_uring_ring.sq.ktail, (jlong)io_uring_ring.sq.ktail,
(jlong)io_uring_ring.sq.kring_mask, (jlong)io_uring_ring.sq.kring_mask,
(jlong)io_uring_ring.sq.kring_entries, (jlong)io_uring_ring.sq.kflags, (jlong)io_uring_ring.sq.kring_entries,
(jlong)io_uring_ring.sq.kdropped, (jlong)io_uring_ring.sq.array, (jlong)io_uring_ring.sq.kflags,
(jlong)io_uring_ring.sq.sqes, (jlong)io_uring_ring.sq.ring_sz, (jlong)io_uring_ring.sq.kdropped,
(jlong)io_uring_ring.cq.ring_ptr, (jint)ring_fd, submitCallback); (jlong)io_uring_ring.sq.array,
(jlong)io_uring_ring.sq.sqes,
(jlong)io_uring_ring.sq.ring_sz,
(jlong)io_uring_ring.cq.ring_ptr,
(jlong)ring_fd
};
(*env)->SetLongArrayRegion(env, submissionArray, 0, 11, submissionArrayElements);
jobject ioUringCompletionQueue = (*env)->NewObject( jlong completionArrayElements[] = {
env, ioUringCompletionQueueClass, ioUringCommpletionQueueMethodId, (jlong)io_uring_ring.cq.khead,
(jlong)io_uring_ring.cq.khead, (jlong)io_uring_ring.cq.ktail, (jlong)io_uring_ring.cq.ktail,
(jlong)io_uring_ring.cq.kring_mask, (jlong)io_uring_ring.cq.kring_mask,
(jlong)io_uring_ring.cq.kring_entries, (jlong)io_uring_ring.cq.kring_entries,
(jlong)io_uring_ring.cq.koverflow, (jlong)io_uring_ring.cq.cqes, (jlong)io_uring_ring.cq.koverflow,
(jlong)io_uring_ring.cq.ring_sz, (jlong)io_uring_ring.cq.ring_ptr, (jlong)io_uring_ring.cq.cqes,
(jint)ring_fd); (jlong)io_uring_ring.cq.ring_sz,
(jlong)io_uring_ring.cq.ring_ptr,
(jlong)ring_fd
};
(*env)->SetLongArrayRegion(env, completionArray, 0, 9, completionArrayElements);
jobject ringBuffer = (*env)->SetObjectArrayElement(env, array, 0, submissionArray);
(*env)->NewObject(env, ringBufferClass, ringBufferMethodId, (*env)->SetObjectArrayElement(env, array, 1, completionArray);
ioUringSubmissionQueue, ioUringCompletionQueue); return array;
return ringBuffer;
} }
static jint netty_create_file(JNIEnv *env, jclass class) { static jint netty_create_file(JNIEnv *env, jclass class) {
@ -386,8 +375,8 @@ static const JNINativeMethod statically_referenced_fixed_method_table[] = {
static const jint statically_referenced_fixed_method_table_size = sizeof(statically_referenced_fixed_method_table) / sizeof(statically_referenced_fixed_method_table[0]); static const jint statically_referenced_fixed_method_table_size = sizeof(statically_referenced_fixed_method_table) / sizeof(statically_referenced_fixed_method_table[0]);
static const JNINativeMethod method_table[] = { static const JNINativeMethod method_table[] = {
{"ioUringSetup", "(ILjava/lang/Runnable;)Lio/netty/channel/uring/RingBuffer;", (void *) netty_io_uring_setup}, {"ioUringSetup", "(I)[[J", (void *) netty_io_uring_setup},
{"ioUringExit", "(Lio/netty/channel/uring/RingBuffer;)V", (void *) netty_io_uring_ring_buffer_exit}, {"ioUringExit", "(JIJIJII)V", (void *) netty_io_uring_ring_buffer_exit},
{"createFile", "()I", (void *) netty_create_file}, {"createFile", "()I", (void *) netty_create_file},
{"ioUringEnter", "(IIII)I", (void *)netty_io_uring_enter}, {"ioUringEnter", "(IIII)I", (void *)netty_io_uring_enter},
{"blockingEventFd", "()I", (void *) netty_epoll_native_blocking_event_fd}, {"blockingEventFd", "()I", (void *) netty_epoll_native_blocking_event_fd},
@ -477,27 +466,7 @@ JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *reserved) {
} }
linuxsocketOnLoadCalled = 1; linuxsocketOnLoadCalled = 1;
NETTY_PREPEND(packagePrefix, "io/netty/channel/uring/RingBuffer", NETTY_LOAD_CLASS(env, longArrayClass, "[J", done);
nettyClassName, done);
NETTY_LOAD_CLASS(env, ringBufferClass, nettyClassName, done);
NETTY_GET_METHOD(env, ringBufferClass, ringBufferMethodId, "<init>",
"(Lio/netty/channel/uring/IOUringSubmissionQueue;Lio/netty/"
"channel/uring/IOUringCompletionQueue;)V",
done);
NETTY_PREPEND(packagePrefix, "io/netty/channel/uring/IOUringSubmissionQueue",
nettyClassName, done);
NETTY_LOAD_CLASS(env, ioUringSubmissionQueueClass, nettyClassName, done);
NETTY_GET_METHOD(env, ioUringSubmissionQueueClass,
ioUringSubmissionQueueMethodId, "<init>", "(JJJJJJJJIJILjava/lang/Runnable;)V",
done);
NETTY_PREPEND(packagePrefix, "io/netty/channel/uring/IOUringCompletionQueue",
nettyClassName, done);
NETTY_LOAD_CLASS(env, ioUringCompletionQueueClass, nettyClassName, done);
NETTY_GET_METHOD(env, ioUringCompletionQueueClass,
ioUringCommpletionQueueMethodId, "<init>", "(JJJJJJIJI)V",
done);
ret = NETTY_JNI_VERSION; ret = NETTY_JNI_VERSION;
done: done:
//unload //unload
@ -522,14 +491,6 @@ done:
if (linuxsocketOnLoadCalled == 1) { if (linuxsocketOnLoadCalled == 1) {
netty_io_uring_linuxsocket_JNI_OnUnLoad(env); netty_io_uring_linuxsocket_JNI_OnUnLoad(env);
} }
ringBufferMethodId = NULL;
ioUringSubmissionQueueMethodId = NULL;
ioUringCommpletionQueueMethodId = NULL;
ringBufferClass = NULL;
ioUringCompletionQueueClass = NULL;
ioUringSubmissionQueueClass = NULL;
} }
return ret; return ret;
} }

View File

@ -703,7 +703,7 @@ abstract class AbstractIOUringChannel extends AbstractChannel implements UnixCha
protected void doRegister() throws Exception { protected void doRegister() throws Exception {
IOUringEventLoop eventLoop = (IOUringEventLoop) eventLoop(); IOUringEventLoop eventLoop = (IOUringEventLoop) eventLoop();
eventLoop.add(this); eventLoop.add(this);
submissionQueue = eventLoop.getRingBuffer().getIoUringSubmissionQueue(); submissionQueue = eventLoop.getRingBuffer().ioUringSubmissionQueue();
} }
@Override @Override

View File

@ -36,9 +36,9 @@ final class IOUringCompletionQueue {
private final long completionQueueArrayAddress; private final long completionQueueArrayAddress;
private final int ringSize; final int ringSize;
private final long ringAddress; final long ringAddress;
private final int ringFd; final int ringFd;
private final int ringMask; private final int ringMask;
private int ringHead; private int ringHead;

View File

@ -131,8 +131,8 @@ final class IOUringEventLoop extends SingleThreadEventLoop implements
@Override @Override
protected void run() { protected void run() {
final IOUringCompletionQueue completionQueue = ringBuffer.getIoUringCompletionQueue(); final IOUringCompletionQueue completionQueue = ringBuffer.ioUringCompletionQueue();
final IOUringSubmissionQueue submissionQueue = ringBuffer.getIoUringSubmissionQueue(); final IOUringSubmissionQueue submissionQueue = ringBuffer.ioUringSubmissionQueue();
// Lets add the eventfd related events before starting to do any real work. // Lets add the eventfd related events before starting to do any real work.
addEventFdRead(submissionQueue); addEventFdRead(submissionQueue);
@ -222,7 +222,7 @@ final class IOUringEventLoop extends SingleThreadEventLoop implements
if (op == Native.IORING_OP_READ && eventfd.intValue() == fd) { if (op == Native.IORING_OP_READ && eventfd.intValue() == fd) {
if (res != Native.ERRNO_ECANCELED_NEGATIVE) { if (res != Native.ERRNO_ECANCELED_NEGATIVE) {
pendingWakeup = false; pendingWakeup = false;
addEventFdRead(ringBuffer.getIoUringSubmissionQueue()); addEventFdRead(ringBuffer.ioUringSubmissionQueue());
} }
} else if (op == Native.IORING_OP_TIMEOUT) { } else if (op == Native.IORING_OP_TIMEOUT) {
if (res == Native.ERRNO_ETIME_NEGATIVE) { if (res == Native.ERRNO_ETIME_NEGATIVE) {
@ -313,7 +313,7 @@ final class IOUringEventLoop extends SingleThreadEventLoop implements
public IovArray iovArray() { public IovArray iovArray() {
IovArray iovArray = iovArrays.next(); IovArray iovArray = iovArrays.next();
if (iovArray == null) { if (iovArray == null) {
ringBuffer.getIoUringSubmissionQueue().submit(); ringBuffer.ioUringSubmissionQueue().submit();
iovArray = iovArrays.next(); iovArray = iovArrays.next();
assert iovArray != null; assert iovArray != null;
} }

View File

@ -51,17 +51,15 @@ final class IOUringSubmissionQueue {
private final long fFlagsAdress; private final long fFlagsAdress;
private final long kDroppedAddress; private final long kDroppedAddress;
private final long arrayAddress; private final long arrayAddress;
final long submissionQueueArrayAddress;
private final long submissionQueueArrayAddress; final int ringEntries;
private final int ringEntries;
private final int ringMask; // = ringEntries - 1 private final int ringMask; // = ringEntries - 1
private final int ringSize; final int ringSize;
private final long ringAddress; final long ringAddress;
private final int ringFd; final int ringFd;
private final Runnable submissionCallback; private final Runnable submissionCallback;
private final long timeoutMemoryAddress; private final long timeoutMemoryAddress;
private int head; private int head;

View File

@ -82,8 +82,7 @@ final class Native {
static final int IOSQE_ASYNC = NativeStaticallyReferencedJniMethods.iosqeAsync(); static final int IOSQE_ASYNC = NativeStaticallyReferencedJniMethods.iosqeAsync();
static RingBuffer createRingBuffer(int ringSize) { static RingBuffer createRingBuffer(int ringSize) {
//Todo throw Exception if it's null return createRingBuffer(ringSize, new Runnable() {
return ioUringSetup(ringSize, new Runnable() {
@Override @Override
public void run() { public void run() {
// Noop // Noop
@ -92,29 +91,56 @@ final class Native {
} }
static RingBuffer createRingBuffer(int ringSize, Runnable submissionCallback) { static RingBuffer createRingBuffer(int ringSize, Runnable submissionCallback) {
//Todo throw Exception if it's null long[][] values = ioUringSetup(ringSize);
return ioUringSetup(ringSize, submissionCallback); assert values.length == 2;
long[] submissionQueueArgs = values[0];
assert submissionQueueArgs.length == 11;
IOUringSubmissionQueue submissionQueue = new IOUringSubmissionQueue(
submissionQueueArgs[0],
submissionQueueArgs[1],
submissionQueueArgs[2],
submissionQueueArgs[3],
submissionQueueArgs[4],
submissionQueueArgs[5],
submissionQueueArgs[6],
submissionQueueArgs[7],
(int) submissionQueueArgs[8],
submissionQueueArgs[9],
(int) submissionQueueArgs[10],
submissionCallback);
long[] completionQueueArgs = values[1];
assert completionQueueArgs.length == 9;
IOUringCompletionQueue completionQueue = new IOUringCompletionQueue(
completionQueueArgs[0],
completionQueueArgs[1],
completionQueueArgs[2],
completionQueueArgs[3],
completionQueueArgs[4],
completionQueueArgs[5],
(int) completionQueueArgs[6],
completionQueueArgs[7],
(int) completionQueueArgs[8]);
return new RingBuffer(submissionQueue, completionQueue);
} }
static RingBuffer createRingBuffer(Runnable submissionCallback) { static RingBuffer createRingBuffer(Runnable submissionCallback) {
return createRingBuffer(DEFAULT_RING_SIZE, submissionCallback); return createRingBuffer(DEFAULT_RING_SIZE, submissionCallback);
} }
private static native RingBuffer ioUringSetup(int entries, Runnable submissionCallback); private static native long[][] ioUringSetup(int entries);
public static native int ioUringEnter(int ringFd, int toSubmit, int minComplete, int flags); public static native int ioUringEnter(int ringFd, int toSubmit, int minComplete, int flags);
public static native int ioUringRegisterEventFd(int ringFd, int eventFd);
public static native int ioUringUnregisterEventFd(int ringFd);
public static native void eventFdWrite(int fd, long value); public static native void eventFdWrite(int fd, long value);
public static FileDescriptor newBlockingEventFd() { public static FileDescriptor newBlockingEventFd() {
return new FileDescriptor(blockingEventFd()); return new FileDescriptor(blockingEventFd());
} }
public static native void ioUringExit(RingBuffer ringBuffer); public static native void ioUringExit(long submissionQueueArrayAddress, int submissionQueueRingEntries,
long submissionQueueRingAddress, int submissionQueueRingSize,
long completionQueueRingAddress, int completionQueueRingSize,
int ringFd);
private static native int blockingEventFd(); private static native int blockingEventFd();

View File

@ -25,16 +25,23 @@ final class RingBuffer {
this.ioUringCompletionQueue = ioUringCompletionQueue; this.ioUringCompletionQueue = ioUringCompletionQueue;
} }
public IOUringSubmissionQueue getIoUringSubmissionQueue() { IOUringSubmissionQueue ioUringSubmissionQueue() {
return this.ioUringSubmissionQueue; return this.ioUringSubmissionQueue;
} }
public IOUringCompletionQueue getIoUringCompletionQueue() { IOUringCompletionQueue ioUringCompletionQueue() {
return this.ioUringCompletionQueue; return this.ioUringCompletionQueue;
} }
public void close() { void close() {
getIoUringSubmissionQueue().release(); ioUringSubmissionQueue.release();
Native.ioUringExit(this); Native.ioUringExit(
ioUringSubmissionQueue.submissionQueueArrayAddress,
ioUringSubmissionQueue.ringEntries,
ioUringSubmissionQueue.ringAddress,
ioUringSubmissionQueue.ringSize,
ioUringCompletionQueue.ringAddress,
ioUringCompletionQueue.ringSize,
ioUringCompletionQueue.ringFd);
} }
} }

View File

@ -37,8 +37,8 @@ public class IOUringSubmissionQueueTest {
RingBuffer ringBuffer = Native.createRingBuffer(8); RingBuffer ringBuffer = Native.createRingBuffer(8);
ByteBuffer buffer = Buffer.allocateDirectWithNativeOrder(128); ByteBuffer buffer = Buffer.allocateDirectWithNativeOrder(128);
try { try {
IOUringSubmissionQueue submissionQueue = ringBuffer.getIoUringSubmissionQueue(); IOUringSubmissionQueue submissionQueue = ringBuffer.ioUringSubmissionQueue();
final IOUringCompletionQueue completionQueue = ringBuffer.getIoUringCompletionQueue(); final IOUringCompletionQueue completionQueue = ringBuffer.ioUringCompletionQueue();
assertNotNull(ringBuffer); assertNotNull(ringBuffer);
assertNotNull(submissionQueue); assertNotNull(submissionQueue);

View File

@ -47,8 +47,8 @@ public class NativeTest {
int fd = Native.createFile(); int fd = Native.createFile();
RingBuffer ringBuffer = Native.createRingBuffer(32); RingBuffer ringBuffer = Native.createRingBuffer(32);
IOUringSubmissionQueue submissionQueue = ringBuffer.getIoUringSubmissionQueue(); IOUringSubmissionQueue submissionQueue = ringBuffer.ioUringSubmissionQueue();
IOUringCompletionQueue completionQueue = ringBuffer.getIoUringCompletionQueue(); IOUringCompletionQueue completionQueue = ringBuffer.ioUringCompletionQueue();
assertNotNull(ringBuffer); assertNotNull(ringBuffer);
assertNotNull(submissionQueue); assertNotNull(submissionQueue);
@ -93,8 +93,8 @@ public class NativeTest {
public void timeoutTest() throws Exception { public void timeoutTest() throws Exception {
RingBuffer ringBuffer = Native.createRingBuffer(32); RingBuffer ringBuffer = Native.createRingBuffer(32);
IOUringSubmissionQueue submissionQueue = ringBuffer.getIoUringSubmissionQueue(); IOUringSubmissionQueue submissionQueue = ringBuffer.ioUringSubmissionQueue();
final IOUringCompletionQueue completionQueue = ringBuffer.getIoUringCompletionQueue(); final IOUringCompletionQueue completionQueue = ringBuffer.ioUringCompletionQueue();
assertNotNull(ringBuffer); assertNotNull(ringBuffer);
assertNotNull(submissionQueue); assertNotNull(submissionQueue);
@ -134,8 +134,8 @@ public class NativeTest {
@Test @Test
public void eventfdTest() throws Exception { public void eventfdTest() throws Exception {
RingBuffer ringBuffer = Native.createRingBuffer(32); RingBuffer ringBuffer = Native.createRingBuffer(32);
IOUringSubmissionQueue submissionQueue = ringBuffer.getIoUringSubmissionQueue(); IOUringSubmissionQueue submissionQueue = ringBuffer.ioUringSubmissionQueue();
final IOUringCompletionQueue completionQueue = ringBuffer.getIoUringCompletionQueue(); final IOUringCompletionQueue completionQueue = ringBuffer.ioUringCompletionQueue();
assertNotNull(ringBuffer); assertNotNull(ringBuffer);
assertNotNull(submissionQueue); assertNotNull(submissionQueue);
@ -173,8 +173,8 @@ public class NativeTest {
public void eventfdNoSignal() throws Exception { public void eventfdNoSignal() throws Exception {
RingBuffer ringBuffer = Native.createRingBuffer(32); RingBuffer ringBuffer = Native.createRingBuffer(32);
IOUringSubmissionQueue submissionQueue = ringBuffer.getIoUringSubmissionQueue(); IOUringSubmissionQueue submissionQueue = ringBuffer.ioUringSubmissionQueue();
final IOUringCompletionQueue completionQueue = ringBuffer.getIoUringCompletionQueue(); final IOUringCompletionQueue completionQueue = ringBuffer.ioUringCompletionQueue();
assertNotNull(ringBuffer); assertNotNull(ringBuffer);
assertNotNull(submissionQueue); assertNotNull(submissionQueue);
@ -223,8 +223,8 @@ public class NativeTest {
@Test @Test
public void ioUringPollRemoveTest() throws Exception { public void ioUringPollRemoveTest() throws Exception {
RingBuffer ringBuffer = Native.createRingBuffer(32); RingBuffer ringBuffer = Native.createRingBuffer(32);
IOUringSubmissionQueue submissionQueue = ringBuffer.getIoUringSubmissionQueue(); IOUringSubmissionQueue submissionQueue = ringBuffer.ioUringSubmissionQueue();
final IOUringCompletionQueue completionQueue = ringBuffer.getIoUringCompletionQueue(); final IOUringCompletionQueue completionQueue = ringBuffer.ioUringCompletionQueue();
FileDescriptor eventFd = Native.newBlockingEventFd(); FileDescriptor eventFd = Native.newBlockingEventFd();
submissionQueue.addPollIn(eventFd.intValue()); submissionQueue.addPollIn(eventFd.intValue());