AsyncConnection优化
This commit is contained in:
@@ -298,23 +298,25 @@ abstract class AsyncNioConnection extends AsyncConnection {
|
|||||||
this.clientModeWriteQueue.offer(data);
|
this.clientModeWriteQueue.offer(data);
|
||||||
this.writeCompletionHandler = (CompletionHandler) handler;
|
this.writeCompletionHandler = (CompletionHandler) handler;
|
||||||
this.writeAttachment = attachment;
|
this.writeAttachment = attachment;
|
||||||
if (writeKey == null) {
|
try {
|
||||||
ioWriteThread.register(selector -> {
|
if (writeKey == null) {
|
||||||
try {
|
ioWriteThread.register(selector -> {
|
||||||
if (writeKey == null) {
|
try {
|
||||||
writeKey = implRegister(selector, SelectionKey.OP_WRITE);
|
if (writeKey == null) {
|
||||||
writeKey.attach(this);
|
writeKey = implRegister(selector, SelectionKey.OP_WRITE);
|
||||||
} else {
|
writeKey.attach(this);
|
||||||
writeKey.interestOps(writeKey.interestOps() | SelectionKey.OP_WRITE);
|
} else {
|
||||||
|
writeKey.interestOps(writeKey.interestOps() | SelectionKey.OP_WRITE);
|
||||||
|
}
|
||||||
|
} catch (ClosedChannelException e) {
|
||||||
|
handleWrite(0, e);
|
||||||
}
|
}
|
||||||
} catch (ClosedChannelException e) {
|
});
|
||||||
this.writeCompletionHandler = (CompletionHandler) handler;
|
} else {
|
||||||
this.writeAttachment = attachment;
|
ioWriteThread.interestOpsOr(writeKey, SelectionKey.OP_WRITE);
|
||||||
handleWrite(0, e);
|
}
|
||||||
}
|
} catch (Exception e) {
|
||||||
});
|
handleWrite(0, e);
|
||||||
} else {
|
|
||||||
ioWriteThread.interestOpsOr(writeKey, SelectionKey.OP_WRITE);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1430,7 +1430,7 @@ public final class CacheMemorySource extends AbstractCacheSource {
|
|||||||
}
|
}
|
||||||
CacheEntry entry = container.get(key);
|
CacheEntry entry = container.get(key);
|
||||||
if (entry == null || !entry.isSetCacheType() || entry.csetValue == null) {
|
if (entry == null || !entry.isSetCacheType() || entry.csetValue == null) {
|
||||||
Set set = cacheType == CacheEntryType.SET_SORTED ? Collections.synchronizedSet(new TreeSet<>()) : new CopyOnWriteArraySet();
|
Set set = cacheType == CacheEntryType.SET_SORTED ? new ConcurrentSkipListSet<>() : new CopyOnWriteArraySet();
|
||||||
entry = new CacheEntry(cacheType, key, null, set, null, null);
|
entry = new CacheEntry(cacheType, key, null, set, null, null);
|
||||||
CacheEntry old = container.putIfAbsent(key, entry);
|
CacheEntry old = container.putIfAbsent(key, entry);
|
||||||
if (old != null) {
|
if (old != null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user