From 8b4078d1de7a76295f73847016e3f231b792c93c Mon Sep 17 00:00:00 2001 From: Ludovic Orban Date: Wed, 26 Jun 2024 09:36:58 +0200 Subject: [PATCH] #11932 simplify queue handling Signed-off-by: Ludovic Orban --- .../jetty/quic/common/QuicConnection.java | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/jetty-core/jetty-quic/jetty-quic-common/src/main/java/org/eclipse/jetty/quic/common/QuicConnection.java b/jetty-core/jetty-quic/jetty-quic-common/src/main/java/org/eclipse/jetty/quic/common/QuicConnection.java index 722d494dbead..e5c1d340b659 100644 --- a/jetty-core/jetty-quic/jetty-quic-common/src/main/java/org/eclipse/jetty/quic/common/QuicConnection.java +++ b/jetty-core/jetty-quic/jetty-quic-common/src/main/java/org/eclipse/jetty/quic/common/QuicConnection.java @@ -17,11 +17,12 @@ import java.net.InetSocketAddress; import java.net.SocketAddress; import java.nio.ByteBuffer; -import java.util.ArrayDeque; import java.util.Collection; import java.util.EventListener; import java.util.List; +import java.util.Queue; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.Executor; @@ -39,7 +40,6 @@ import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.IteratingCallback; import org.eclipse.jetty.util.component.LifeCycle; -import org.eclipse.jetty.util.thread.AutoLock; import org.eclipse.jetty.util.thread.ExecutionStrategy; import org.eclipse.jetty.util.thread.Scheduler; import org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy; @@ -344,26 +344,19 @@ public Runnable produce() private class Flusher extends IteratingCallback { - private final AutoLock lock = new AutoLock(); - private final ArrayDeque queue = new ArrayDeque<>(); + private final Queue queue = new ConcurrentLinkedQueue<>(); private Entry entry; public void offer(Callback callback, SocketAddress address, ByteBuffer[] buffers) { - try (AutoLock l = lock.lock()) - { - queue.offer(new Entry(callback, address, buffers)); - } + queue.offer(new Entry(callback, address, buffers)); iterate(); } @Override protected Action process() { - try (AutoLock l = lock.lock()) - { - entry = queue.poll(); - } + entry = queue.poll(); if (entry == null) return Action.IDLE;