This commit is contained in:
@@ -118,7 +118,6 @@ public abstract class AsyncConnection implements ReadableByteChannel, WritableBy
|
|||||||
|
|
||||||
public abstract void read(CompletionHandler<Integer, ByteBuffer> handler);
|
public abstract void read(CompletionHandler<Integer, ByteBuffer> handler);
|
||||||
|
|
||||||
public abstract void read(long timeout, TimeUnit unit, CompletionHandler<Integer, ByteBuffer> handler);
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public abstract int write(ByteBuffer src) throws IOException;
|
public abstract int write(ByteBuffer src) throws IOException;
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ package org.redkale.net;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.*;
|
import java.nio.*;
|
||||||
import java.nio.channels.*;
|
import java.nio.channels.*;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.logging.*;
|
import java.util.logging.*;
|
||||||
import org.redkale.util.*;
|
import org.redkale.util.*;
|
||||||
@@ -44,7 +43,6 @@ public class PrepareRunner implements Runnable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
final boolean keepalive = response != null;
|
|
||||||
if (data != null) { //BIO模式的UDP连接创建AsyncConnection时已经获取到ByteBuffer数据了
|
if (data != null) { //BIO模式的UDP连接创建AsyncConnection时已经获取到ByteBuffer数据了
|
||||||
if (response == null) response = responsePool.get();
|
if (response == null) response = responsePool.get();
|
||||||
try {
|
try {
|
||||||
@@ -58,8 +56,7 @@ public class PrepareRunner implements Runnable {
|
|||||||
}
|
}
|
||||||
if (response == null) response = responsePool.get();
|
if (response == null) response = responsePool.get();
|
||||||
try {
|
try {
|
||||||
channel.read(keepalive ? context.getAliveTimeoutSeconds() : context.getReadTimeoutSeconds(), TimeUnit.SECONDS,
|
channel.read(new CompletionHandler<Integer, ByteBuffer>() {
|
||||||
new CompletionHandler<Integer, ByteBuffer>() {
|
|
||||||
@Override
|
@Override
|
||||||
public void completed(Integer count, ByteBuffer buffer) {
|
public void completed(Integer count, ByteBuffer buffer) {
|
||||||
if (count < 1) {
|
if (count < 1) {
|
||||||
|
|||||||
@@ -103,13 +103,6 @@ public class TcpAioAsyncConnection extends AsyncConnection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void read(long timeout, TimeUnit unit, CompletionHandler<Integer, ByteBuffer> handler) {
|
|
||||||
this.readtime = System.currentTimeMillis();
|
|
||||||
ByteBuffer dst = pollReadBuffer();
|
|
||||||
channel.read(dst, timeout < 0 ? 0 : timeout, unit, dst, handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
private <A> void nextWrite(Throwable exc, A attachment) {
|
private <A> void nextWrite(Throwable exc, A attachment) {
|
||||||
BlockingQueue<WriteEntry> queue = this.writeQueue;
|
BlockingQueue<WriteEntry> queue = this.writeQueue;
|
||||||
if (queue != null && exc != null && !isOpen()) {
|
if (queue != null && exc != null && !isOpen()) {
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import java.net.*;
|
|||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.channels.*;
|
import java.nio.channels.*;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.*;
|
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
import java.util.function.*;
|
import java.util.function.*;
|
||||||
import javax.net.ssl.SSLContext;
|
import javax.net.ssl.SSLContext;
|
||||||
@@ -142,11 +141,6 @@ public class UdpBioAsyncConnection extends AsyncConnection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void read(long timeout, TimeUnit unit, CompletionHandler<Integer, ByteBuffer> handler) {
|
|
||||||
read(handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int read(ByteBuffer dst) throws IOException {
|
public int read(ByteBuffer dst) throws IOException {
|
||||||
int rs = channel.read(dst);
|
int rs = channel.read(dst);
|
||||||
|
|||||||
Reference in New Issue
Block a user