This commit is contained in:
@@ -60,9 +60,7 @@ public final class PrepareRunner implements Runnable {
|
||||
}
|
||||
// { //测试
|
||||
// buffer.flip();
|
||||
// byte[] bytes = new byte[buffer.remaining()];
|
||||
// buffer.get(bytes);
|
||||
// System.println(new String(bytes));
|
||||
// System.println(new String(buffer.array(), 0, buffer.remaining()));
|
||||
// }
|
||||
buffer.flip();
|
||||
final Response response = responsePool.poll();
|
||||
|
||||
@@ -90,4 +90,9 @@ public abstract class Request {
|
||||
public Context getContext() {
|
||||
return this.context;
|
||||
}
|
||||
|
||||
public long getCreatetime() {
|
||||
return createtime;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,6 +24,8 @@ public abstract class Response<R extends Request> {
|
||||
|
||||
private boolean inited = true;
|
||||
|
||||
protected Runnable recycleListener;
|
||||
|
||||
private final CompletionHandler finishHandler = new CompletionHandler<Integer, ByteBuffer>() {
|
||||
|
||||
@Override
|
||||
@@ -96,6 +98,13 @@ public abstract class Response<R extends Request> {
|
||||
protected boolean recycle() {
|
||||
if (!inited) return false;
|
||||
boolean keepAlive = request.keepAlive;
|
||||
if (recycleListener != null) {
|
||||
try {
|
||||
recycleListener.run();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
recycleListener = null;
|
||||
}
|
||||
request.recycle();
|
||||
if (channel != null) {
|
||||
if (keepAlive) {
|
||||
@@ -122,6 +131,10 @@ public abstract class Response<R extends Request> {
|
||||
this.request.createtime = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public void setRecycleListener(Runnable recycleListener) {
|
||||
this.recycleListener = recycleListener;
|
||||
}
|
||||
|
||||
public void finish() {
|
||||
this.finish(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user