From aeb2ba51c5a2470eefb1f8db3f0d2a5b7df300ea Mon Sep 17 00:00:00 2001 From: He-Pin Date: Mon, 6 Jan 2025 01:50:38 +0800 Subject: [PATCH] chore: Avoid forwarding method on ArrayDequeue in BatchingExecutor. --- .../org/apache/pekko/dispatch/BatchingExecutor.scala | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/actor/src/main/scala/org/apache/pekko/dispatch/BatchingExecutor.scala b/actor/src/main/scala/org/apache/pekko/dispatch/BatchingExecutor.scala index 437989654fe..634c3a6dd9b 100644 --- a/actor/src/main/scala/org/apache/pekko/dispatch/BatchingExecutor.scala +++ b/actor/src/main/scala/org/apache/pekko/dispatch/BatchingExecutor.scala @@ -16,7 +16,7 @@ package org.apache.pekko.dispatch import org.apache.pekko import pekko.annotation.InternalApi -import java.util.ArrayDeque +import java.util import java.util.concurrent.Executor import scala.annotation.tailrec import scala.concurrent._ @@ -67,10 +67,10 @@ private[pekko] trait BatchingExecutor extends Executor { // invariant: if "_tasksLocal.get ne null" then we are inside Batch.run; if it is null, we are outside private[this] val _tasksLocal = new ThreadLocal[AbstractBatch]() - private[this] abstract class AbstractBatch extends ArrayDeque[Runnable](4) with Runnable { + private[this] abstract class AbstractBatch extends util.ArrayDeque[Runnable](4) with Runnable { @tailrec final def processBatch(batch: AbstractBatch): Unit = if ((batch eq this) && !batch.isEmpty) { - batch.poll().run() + batch.pollFirst().run() processBatch(_tasksLocal.get) // If this is null, then we have been using managed blocking, so bail out } @@ -85,7 +85,7 @@ private[pekko] trait BatchingExecutor extends Executor { } private[this] final class Batch extends AbstractBatch { - override final def run: Unit = { + override final def run(): Unit = { require(_tasksLocal.get eq null) _tasksLocal.set(this) // Install ourselves as the current batch try processBatch(this)