@@ -85,7 +85,6 @@ public final class IoUringIoHandler implements IoHandler {
8585 private static final int KERNEL_TIMESPEC_TV_SEC_FIELD = 0 ;
8686 private static final int KERNEL_TIMESPEC_TV_NSEC_FIELD = 8 ;
8787
88- private final CompletionBuffer completionBuffer ;
8988 private final ThreadAwareExecutor executor ;
9089
9190 IoUringIoHandler (ThreadAwareExecutor executor , IoUringIoHandlerConfig config ) {
@@ -148,10 +147,6 @@ public final class IoUringIoHandler implements IoHandler {
148147 timeoutMemoryCleanable = Buffer .allocateDirectBufferWithNativeOrder (KERNEL_TIMESPEC_SIZE );
149148 timeoutMemory = timeoutMemoryCleanable .buffer ();
150149 timeoutMemoryAddress = Buffer .memoryAddress (timeoutMemory );
151- // We buffer a maximum of 2 * CompletionQueue.ringCapacity completions before we drain them in batches.
152- // Also as we never submit an udata which is 0L we use this as the tombstone marker.
153- completionBuffer = new CompletionBuffer (ringBuffer .ioUringCompletionQueue ().ringCapacity * 2 , 0 );
154-
155150 iovArray = new IovArray (IoUring .NUM_ELEMENTS_IOVEC );
156151 }
157152
@@ -181,19 +176,7 @@ public int run(IoHandlerContext context) {
181176 // Even if we have some completions already pending we can still try to even fetch more.
182177 submitAndClearNow (submissionQueue );
183178 }
184- return drainAndProcessAll (completionQueue , this ::handle );
185- }
186-
187- void submitAndRunNow (long udata ) {
188- if (closeCompleted ) {
189- return ;
190- }
191- SubmissionQueue submissionQueue = ringBuffer .ioUringSubmissionQueue ();
192- CompletionQueue completionQueue = ringBuffer .ioUringCompletionQueue ();
193- if (submitAndClearNow (submissionQueue ) > 0 ) {
194- completionBuffer .drain (completionQueue );
195- completionBuffer .processOneNow (this ::handle , udata );
196- }
179+ return completionQueue .process (this ::handle );
197180 }
198181
199182 private int submitAndClearNow (SubmissionQueue submissionQueue ) {
@@ -232,18 +215,6 @@ IoUringBufferRing findBufferRing(short bgId) {
232215 );
233216 }
234217
235- private int drainAndProcessAll (CompletionQueue completionQueue , CompletionCallback callback ) {
236- int processed = 0 ;
237- for (;;) {
238- boolean drainedAll = completionBuffer .drain (completionQueue );
239- processed += completionBuffer .processNow (callback );
240- if (drainedAll ) {
241- break ;
242- }
243- }
244- return processed ;
245- }
246-
247218 private static void handleLoopException (Throwable throwable ) {
248219 logger .warn ("Unexpected exception in the IO event loop." , throwable );
249220
@@ -424,11 +395,10 @@ public boolean handle(int res, int flags, long udata) {
424395 }
425396 }
426397 final DrainFdEventCallback handler = new DrainFdEventCallback ();
427- drainAndProcessAll (completionQueue , handler );
428398 completionQueue .process (handler );
429399 while (!handler .eventFdDrained ) {
430400 submissionQueue .submitAndGet ();
431- drainAndProcessAll ( completionQueue , handler );
401+ completionQueue . process ( handler );
432402 }
433403 }
434404 // We've consumed any pending eventfd read and `eventfdAsyncNotify` should never
0 commit comments