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