Removing Synchronization performed on java.util.concurrent.ConcurrentLinkedDeque object in class NettyConnection
This commit is contained in:
parent
958d746692
commit
1c2164adad
|
@ -18,8 +18,8 @@ package org.apache.activemq.artemis.core.remoting.impl.netty;
|
||||||
|
|
||||||
import java.net.SocketAddress;
|
import java.net.SocketAddress;
|
||||||
import java.util.Deque;
|
import java.util.Deque;
|
||||||
|
import java.util.LinkedList;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.LinkedBlockingDeque;
|
|
||||||
import java.util.concurrent.Semaphore;
|
import java.util.concurrent.Semaphore;
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
|
@ -71,7 +71,7 @@ public class NettyConnection implements Connection {
|
||||||
|
|
||||||
/** if {@link #isWritable(ReadyListener)} returns false, we add a callback
|
/** if {@link #isWritable(ReadyListener)} returns false, we add a callback
|
||||||
* here for when the connection (or Netty Channel) becomes available again. */
|
* here for when the connection (or Netty Channel) becomes available again. */
|
||||||
private final Deque<ReadyListener> readyListeners = new LinkedBlockingDeque<>();
|
private final Deque<ReadyListener> readyListeners = new LinkedList<>();
|
||||||
|
|
||||||
// Static --------------------------------------------------------
|
// Static --------------------------------------------------------
|
||||||
|
|
||||||
|
@ -102,34 +102,30 @@ public class NettyConnection implements Connection {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isWritable(ReadyListener callback) {
|
public synchronized boolean isWritable(ReadyListener callback) {
|
||||||
synchronized (readyListeners) {
|
if (!ready) {
|
||||||
if (!ready) {
|
readyListeners.push(callback);
|
||||||
readyListeners.push(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ready;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return ready;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fireReady(final boolean ready) {
|
public synchronized void fireReady(final boolean ready) {
|
||||||
synchronized (readyListeners) {
|
this.ready = ready;
|
||||||
this.ready = ready;
|
|
||||||
|
|
||||||
if (ready) {
|
if (ready) {
|
||||||
for (;;) {
|
for (;;) {
|
||||||
ReadyListener readyListener = readyListeners.poll();
|
ReadyListener readyListener = readyListeners.poll();
|
||||||
if (readyListener == null) {
|
if (readyListener == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
readyListener.readyForWriting();
|
readyListener.readyForWriting();
|
||||||
}
|
}
|
||||||
catch (Throwable logOnly) {
|
catch (Throwable logOnly) {
|
||||||
ActiveMQClientLogger.LOGGER.warn(logOnly.getMessage(), logOnly);
|
ActiveMQClientLogger.LOGGER.warn(logOnly.getMessage(), logOnly);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue